Skip to content

Commit 36eb57c

Browse files
authored
Merge pull request #22 from Roblox/ICO-4170-add-data-symlink
ICO-4170: Add vault /data symlink
2 parents 8d2f73b + 8fc74ae commit 36eb57c

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

libraries/vault_service.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ def action_enable
8484
not_if { new_resource.disable_mlock }
8585
not_if "getcap #{new_resource.program}|grep cap_ipc_lock+ep"
8686
end
87+
88+
# if /data directory mounted then we need to symlink /var/log/vault to /data/var/log/vault
89+
if ::File.directory?('/data')
90+
link '/var/log/vault' do
91+
to ::File.join('/data', '/var/log/vault')
92+
action :create
93+
end
94+
end
8795
end
8896
super
8997
end

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
long_description 'Application cookbook for installing and configuring Vault.'
77
issues_url 'https://github.com/johnbellone/vault-cookbook/issues'
88
source_url 'https://github.com/johnbellone/vault-cookbook/'
9-
version '1002.7.8'
9+
version '1002.7.9'
1010

1111
supports 'ubuntu', '>= 12.04'
1212
supports 'redhat', '>= 6.4'

test/fixtures/policies/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
default_source :supermarket
33
default_source :chef_repo, '..'
44
cookbook 'hashicorp-vault', path: '../../..'
5+
cookbook 'mingw', '2.1.1'
56
run_list 'hashicorp-vault::default'

test/unit/libraries/vault_service_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@
1212

1313
before do
1414
stub_command('getcap /opt/vault/0.9.1/vault|grep cap_ipc_lock+ep').and_return(false)
15+
16+
# Create the /data directory to simulate the mount
17+
allow(File).to receive(:directory?).with('/data').and_return(true)
1518
end
1619

1720
context 'with default properties' do
1821
it { is_expected.to run_execute 'setcap cap_ipc_lock=+ep /opt/vault/0.9.1/vault' }
22+
23+
#Test for symlink creation
24+
it 'creates a symlink for /var/log/vault to /data/var/log/vault' do
25+
expect(chef_run).to create_link('/var/log/vault').with(to: '/data/var/log/vault')
1926
end
2027
end

0 commit comments

Comments
 (0)