Commit e8135860 authored by Christopher Huhn's avatar Christopher Huhn 🥚
Browse files

Don't manage chef-client service in case of systemd timer setup

parent f109bdec
...@@ -20,5 +20,5 @@ end ...@@ -20,5 +20,5 @@ end
default_unless['sys']['chef']['restart_via_cron'] = false default_unless['sys']['chef']['restart_via_cron'] = false
if node['platform_family'] == 'rhel' if node['platform_family'] == 'rhel'
default_unless['sys']['chef']['init_style'] = 'systemd' default_unless['sys']['chef']['init_style'] = 'systemd-timer'
end end
...@@ -125,7 +125,10 @@ if node['sys']['chef']['restart_via_cron'] # ~FC023 ...@@ -125,7 +125,10 @@ if node['sys']['chef']['restart_via_cron'] # ~FC023
end end
end end
if node['sys']['chef']['init_style'] == 'systemd' if node['sys']['chef']['init_style'] == 'systemd-timer'
# creates a one shot service and a systemd.timer to trigger it
# mimic the chef-client cookbook systemd unit: # mimic the chef-client cookbook systemd unit:
systemd_unit 'chef-client.service' do systemd_unit 'chef-client.service' do
content( content(
...@@ -158,19 +161,24 @@ if node['sys']['chef']['init_style'] == 'systemd' ...@@ -158,19 +161,24 @@ if node['sys']['chef']['init_style'] == 'systemd'
) )
action [:create, :enable, :start] action [:create, :enable, :start]
end end
else else
# normal systemd/sysvinit service
# Comments in systemctl-src say that update-rc.d does not provide # Comments in systemctl-src say that update-rc.d does not provide
# information wheter a service is enabled or not and always returns # information wheter a service is enabled or not and always returns
# false. Work around that. # false. Work around that.
actions = [:start] actions = [:start]
actions << :enable if Dir.glob('/etc/rc2.d/*chef-client*').empty? actions << :enable if Dir.glob('/etc/rc2.d/*chef-client*').empty?
actions << :enable if Dir.glob('/etc/rc2.d/*chef-client*').empty? actions << :enable if Dir.glob('/etc/rc2.d/*chef-client*').empty?
end
service 'chef-client' do service 'chef-client' do
supports :restart => true, :status => true supports :restart => true, :status => true
action actions action actions
ignore_failure true ignore_failure true
subscribes :restart, 'template[/etc/default/chef-client]' subscribes :restart, 'template[/etc/default/chef-client]'
subscribes :restart, 'template[/etc/chef/client.rb]' subscribes :restart, 'template[/etc/chef/client.rb]'
end
end end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment