haproxy: Can't send haproxy service notifications

Cookbook version

5.0.0

Chef-client version

12.20

Platform Details

Ubuntu 16.04

Scenario:

I want to send haproxy a reload notification when other files are updated. For example when an SSL cert is updated.

Steps to Reproduce:

In haproxy cookbook 2.x I could do this and it would reload haproxy when the cert file was updated.

file '/etc/haproxy/ssl/haproxy.pem' do
  owner 'root'
  group 'root'
  mode '0400'
  sensitive true
  content "my-cert"
  notifies :reload, 'service[haproxy]'
end

As a workaround I can add

service 'poise_haproxy' do
  action :nothing
end

and do notifies :reload, 'poise_service[haproxy]'

but it would be nice if resource notifications worked out of the box.

Expected Result:

I expect there to be a way to send haproxy reload notifications.

Actual Result:

[2017-10-12T23:20:02+00:00] ERROR: resource file[/etc/haproxy/ssl/haproxy.pem] is configured to   
 notify resource service[haproxy] with action reload, but service[haproxy] cannot be found in the  
 resource collection. file[/etc/haproxy/ssl/haproxy.pem] is defined in  
 /tmp/kitchen/cache/cookbooks/my-thing/recipes/proxy.rb:27:in `from_file'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I had similar issue but was able to work around it by adding subscribes option in the service haproxy resource.

haproxy_service 'haproxy' do
  source_version node['haproxy']['version']
  subscribes :reload, 'template[/etc/haproxy/haproxy.cfg]', :immediately
end

yes I can, but it’ll take me a few days, I have to finish a big project for work at the moment.