Skip to content

Commit

Permalink
set correct etc config directory for default consul behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil committed Oct 29, 2014
1 parent 8078066 commit ec28d22
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
8 changes: 7 additions & 1 deletion recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@

case node['consul']['init_style']
when 'init'
template '/etc/sysconfig/consul' do
if platform_family?('debian')
etc_config_dir = '/etc/default/consul'
else
etc_config_dir = '/etc/sysconfig/consul'
end

template etc_config_dir do
source 'consul-sysconfig.erb'
mode 0755
notifies :create, 'template[/etc/init.d/consul]', :immediately
Expand Down
30 changes: 25 additions & 5 deletions spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
.with(group: 'root')
.with(mode: 0600)
end
it do
expect(chef_run).to create_template('/etc/init.d/consul')
.with(source: 'consul-init.erb')
.with(mode: 0755)
end
it do
expect(chef_run).to enable_service('consul')
.with(supports: {status: true, restart: true, reload: true})
expect(chef_run).to start_service('consul')
end
end

context 'config on centos' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'centos', version: '6.3').converge(described_recipe)
end
it do
expect(chef_run).to create_template('/etc/sysconfig/consul')
.with(source: 'consul-sysconfig.erb')
Expand All @@ -26,15 +42,19 @@
it do
expect(chef_run).to render_file('/etc/sysconfig/consul').with_content('GOMAXPROCS=1')
end
end

context 'config on ubuntu' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '14.04').converge(described_recipe)
end
it do
expect(chef_run).to create_template('/etc/init.d/consul')
.with(source: 'consul-init.erb')
expect(chef_run).to create_template('/etc/default/consul')
.with(source: 'consul-sysconfig.erb')
.with(mode: 0755)
end
it do
expect(chef_run).to enable_service('consul')
.with(supports: {status: true, restart: true, reload: true})
expect(chef_run).to start_service('consul')
expect(chef_run).to render_file('/etc/default/consul').with_content('GOMAXPROCS=1')
end
end

Expand Down

0 comments on commit ec28d22

Please sign in to comment.