Skip to content

Commit d8e9250

Browse files
authored
Merge pull request #27 from Roblox/create_var_log_vault_directory_in_cookbook
Adding /var/log/vault creation to vault_service.rb
2 parents b371eb1 + 8ad3efd commit d8e9250

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

libraries/vault_service.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,30 @@ def action_enable
8686
end
8787

8888
# if /data directory mounted then we need to symlink /var/log/vault to /data/var/log/vault
89+
log_path = ::File.join('var', 'log', 'vault')
8990
if ::File.directory?('/data')
9091
# 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.ctime(path).strftime('%Y%m%d%H%M%S')
94-
new_path = "#{path}.#{created_at}"
95-
::FileUtils.mv(path, new_path)
92+
data_path = ::File.join('data', log_path)
93+
if ::File.directory?(log_path) && !::File.symlink?(log_path)
94+
created_at = ::File.ctime(log_path).strftime('%Y%m%d%H%M%S')
95+
new_path = ::File.join(log_path, created_at)
96+
::FileUtils.mv(log_path, new_path)
9697
end
97-
directory '/data/var/log/vault' do
98+
directory data_path do
9899
owner new_resource.user
99100
group new_resource.group
100-
mode '0755'
101+
mode '0750'
101102
action :create
102103
end
103-
link '/var/log/vault' do
104-
to ::File.join('/data', '/var/log/vault')
104+
link log_path do
105+
to data_path
106+
action :create
107+
end
108+
else
109+
directory log_path do
110+
owner new_resource.user
111+
group new_resource.group
112+
mode '0750'
105113
action :create
106114
end
107115
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.13'
9+
version '1002.7.14'
1010

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

test/fixtures/policies/default.lock.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"revision_id": "ae657b6f724afe4916c060a6570940a53a92b5fa08f5fb9045c32fc079faf486",
2+
"revision_id": "59638ac2d01c191df467c767cbf6c12e168b209a47f4bc6677a62c73587a3a81",
33
"name": "default",
44
"run_list": [
55
"recipe[hashicorp-vault::default]"
@@ -42,20 +42,19 @@
4242
}
4343
},
4444
"hashicorp-vault": {
45-
"version": "1002.7.7",
46-
"identifier": "c396b582d67d7c9fa0ce0f396e7ec815f3664a38",
47-
"dotted_decimal_identifier": "55053326786919804.44931328176123518.219996603435576",
45+
"version": "1002.7.14",
46+
"identifier": "f587e66bf37fb7bcc5f5c0e40691b6c9c5e749d6",
47+
"dotted_decimal_identifier": "69110793017458615.53134954915432081.200977724950998",
4848
"source": "../../..",
4949
"cache_key": null,
5050
"scm_info": {
5151
"scm": "git",
52-
"remote": "https://github.com/Roblox/vault-cookbook",
53-
"revision": "6ed840d2110e1a6e10714920d45782c6f915b451",
52+
"remote": null,
53+
"revision": "3443293dd9c1e9571e8b49f4ad2d33db00a58c46",
5454
"working_tree_clean": false,
5555
"published": true,
5656
"synchronized_remote_branches": [
57-
"origin/HEAD -> origin/master",
58-
"origin/master"
57+
"origin/create_var_log_vault_directory_in_cookbook"
5958
]
6059
},
6160
"source_options": {
@@ -201,7 +200,7 @@
201200
"~> 5.0"
202201
]
203202
],
204-
"hashicorp-vault (1002.7.7)": [
203+
"hashicorp-vault (1002.7.14)": [
205204
[
206205
"build-essential",
207206
">= 0.0.0"

test/integration/default/inspec/default_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
it { should be_executable }
44
end
55

6+
describe file('/var/log/vault') do
7+
it { should be_directory }
8+
end
9+
610
describe group('vault') do
711
it { should exist }
812
end

0 commit comments

Comments
 (0)