Skip to content

Commit

Permalink
Merge pull request #361 from pdf/allow_disable_create_service_user
Browse files Browse the repository at this point in the history
Allow disabling create_service_user
  • Loading branch information
johnbellone authored Nov 2, 2016
2 parents a7e9cf4 + f58ad83 commit fe538b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
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

0 comments on commit fe538b2

Please sign in to comment.