Hello,
if I am not mistaken a “template” resource can notify a “service” resource if it changes just using notifies in it.
I have this code:
service ‘sssd’ do
supports :restart => true
action :nothing
end
if node[‘platform_family’] == ‘rhel’ && node[‘platform’] == 'redhat’
so_version = node[‘platform_version’].match(/^(\d+)/)
if so_version[0] == “6” || so_version[0] == “7” then
directory ‘/etc/sssd’ do
owner 'root’
group 'root’
mode '0600’
action :create
end
template ‘/etc/sssd/sssd.conf’ do
source 'sssd.conf.erb’
owner 'root’
group 'root’
mode 0600
notifies :restart, ‘service[sssd]’, :immediate
end
end
end
I would expect that as soon as the file /etc/sssd/sssd.conf changes it would be reverted to the template source and the service sssd would be restarted.
However just the /etc/sssd/sssd.conf file is reverted to the template but the sssd service is not restarted.
What am I doing wrong?
That looks correct. What does Chef log after it updates the template; do you see a log message about the notification?
If so, I’d recommend checking journald (in the RHEL 7 case) and seeing if anything obvious is there.
(you can also do node['platform_version'].to_i >= 6 rather than the match and check you have, but that’s not going to affect the chef run)
I did some test and I can say that nic_chef’s way works fine where mine did not.
It looks there is something I did not understand @nic_chef could you explain me why?
@thommay
I’ll be glad to help you.
Let me know what is the most convenient way to help you troubleshooting the issue.
Do you need the /var/log/chef/client.log only?
Should I attach it here or do you prefer using another way?