Skip to content

Commit

Permalink
Merge pull request #22 from Roblox/ICO-4170-add-data-symlink
Browse files Browse the repository at this point in the history
ICO-4170: Add vault /data symlink
  • Loading branch information
roberteckert authored Sep 6, 2024
2 parents 8d2f73b + 8fc74ae commit 36eb57c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions libraries/vault_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ def action_enable
not_if { new_resource.disable_mlock }
not_if "getcap #{new_resource.program}|grep cap_ipc_lock+ep"
end

# if /data directory mounted then we need to symlink /var/log/vault to /data/var/log/vault
if ::File.directory?('/data')
link '/var/log/vault' do
to ::File.join('/data', '/var/log/vault')
action :create
end
end
end
super
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description 'Application cookbook for installing and configuring Vault.'
issues_url 'https://github.com/johnbellone/vault-cookbook/issues'
source_url 'https://github.com/johnbellone/vault-cookbook/'
version '1002.7.8'
version '1002.7.9'

supports 'ubuntu', '>= 12.04'
supports 'redhat', '>= 6.4'
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/policies/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
default_source :supermarket
default_source :chef_repo, '..'
cookbook 'hashicorp-vault', path: '../../..'
cookbook 'mingw', '2.1.1'
run_list 'hashicorp-vault::default'
7 changes: 7 additions & 0 deletions test/unit/libraries/vault_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@

before do
stub_command('getcap /opt/vault/0.9.1/vault|grep cap_ipc_lock+ep').and_return(false)

# Create the /data directory to simulate the mount
allow(File).to receive(:directory?).with('/data').and_return(true)
end

context 'with default properties' do
it { is_expected.to run_execute 'setcap cap_ipc_lock=+ep /opt/vault/0.9.1/vault' }

#Test for symlink creation
it 'creates a symlink for /var/log/vault to /data/var/log/vault' do
expect(chef_run).to create_link('/var/log/vault').with(to: '/data/var/log/vault')
end
end

0 comments on commit 36eb57c

Please sign in to comment.