Skip to content

Commit fe538b2

Browse files
authored
Merge pull request #361 from pdf/allow_disable_create_service_user
Allow disabling create_service_user
2 parents a7e9cf4 + f58ad83 commit fe538b2

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

attributes/default.rb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
default['consul']['service_name'] = 'consul'
99
default['consul']['service_user'] = 'consul'
1010
default['consul']['service_group'] = 'consul'
11+
default['consul']['create_service_user'] = true
1112

1213
default['consul']['config']['owner'] = 'consul'
1314
default['consul']['config']['group'] = 'consul'

recipes/default.rb

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
shell node['consul']['service_shell'] unless node['consul']['service_shell'].nil?
4040
not_if { windows? }
4141
not_if { node['consul']['service_user'] == 'root' }
42+
not_if { node['consul']['create_service_user'] == false }
4243
notifies :restart, "consul_service[#{service_name}]", :delayed
4344
end
4445

test/spec/recipes/default_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@
2020
expect(chef_run).to_not create_poise_service_user('root')
2121
end
2222
end
23+
24+
context "with create_service_user disabled" do
25+
before do
26+
default_attributes['consul'] ||= {}
27+
default_attributes['consul']['create_service_user'] = false
28+
end
29+
30+
it 'does not try to create the user' do
31+
expect(chef_run).to_not create_poise_service_user('consul')
32+
end
33+
end
2334
end

0 commit comments

Comments
 (0)