Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling create_service_user #361

Merged
merged 1 commit into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
default['consul']['service_name'] = 'consul'
default['consul']['service_user'] = 'consul'
default['consul']['service_group'] = 'consul'
default['consul']['create_service_user'] = true

default['consul']['config']['owner'] = 'consul'
default['consul']['config']['group'] = 'consul'
Expand Down
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
shell node['consul']['service_shell'] unless node['consul']['service_shell'].nil?
not_if { windows? }
not_if { node['consul']['service_user'] == 'root' }
not_if { node['consul']['create_service_user'] == false }
notifies :restart, "consul_service[#{service_name}]", :delayed
end

Expand Down
11 changes: 11 additions & 0 deletions test/spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
expect(chef_run).to_not create_poise_service_user('root')
end
end

context "with create_service_user disabled" do
before do
default_attributes['consul'] ||= {}
default_attributes['consul']['create_service_user'] = false
end

it 'does not try to create the user' do
expect(chef_run).to_not create_poise_service_user('consul')
end
end
end