Skip to content

Commit c523bb9

Browse files
authored
Merge pull request #23 from Roblox/ICO-4170-add-data-symlink
ICO-4170: Move vault data if its not already linked
2 parents 36eb57c + b06f1fb commit c523bb9

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

.kitchen.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ suites:
2727
- name: default
2828
provisioner: &default-provisioner
2929
policyfile: test/fixtures/policies/default.rb
30+
- name: test_data_dir
31+
provisioner:
32+
<<: *default-provisioner
33+
policyfile: test/fixtures/policies/default.rb
34+
lifecycle:
35+
post_create:
36+
- remote: sudo mkdir -p /data
3037
- name: test_unauthenticated_metrics
3138
provisioner:
3239
<<: *default-provisioner

libraries/vault_service.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ def action_enable
8787

8888
# if /data directory mounted then we need to symlink /var/log/vault to /data/var/log/vault
8989
if ::File.directory?('/data')
90+
# if /var/log/vault exists and is not a link, move to /var/log/vault.[created_at timestamp]
91+
path = '/var/log/vault'
92+
if ::File.directory?(path) && !::File.symlink?(path)
93+
created_at = ::File.birthtime(path).strftime('%Y%m%d%H%M%S')
94+
new_path = "#{path}.#{created_at}"
95+
::FileUtils.mv(path, new_path)
96+
end
9097
link '/var/log/vault' do
9198
to ::File.join('/data', '/var/log/vault')
9299
action :create

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.9'
9+
version '1002.7.10'
1010

1111
supports 'ubuntu', '>= 12.04'
1212
supports 'redhat', '>= 6.4'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
describe file('/opt/vault/1.8.5/vault') do
2+
it { should be_file }
3+
it { should be_executable }
4+
end
5+
6+
describe group('vault') do
7+
it { should exist }
8+
end
9+
10+
describe user('vault') do
11+
it { should exist }
12+
end
13+
14+
describe file('/etc/vault/vault.json') do
15+
its('mode') { should eq 0640 }
16+
it { should be_file }
17+
it { should be_owned_by 'vault' }
18+
it { should be_grouped_into 'vault' }
19+
its('content') { should match /.*log_level.*/ }
20+
its('content') { should match /.*reporting.*/ }
21+
end
22+
23+
describe file('/var/log/vault') do
24+
it {should be_symlink}
25+
end
26+
27+
describe service('vault') do
28+
it { should be_installed }
29+
it { should be_enabled }
30+
it { should be_running }
31+
end

0 commit comments

Comments
 (0)