Berlin
Berlin

Reputation: 1464

Restart Nginx service on Centos 7 via chef

I'm trying to configure nginx service using chef but Im getting the error below.

Chef::Exceptions::Service
-------------------------
service[nginx]: unable to locate the init.d script!


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/xxx/recipes/default.rb

 23: service 'nginx' do
 24:   supports :status => true, :restart => true, :reload => true
 25:   action   :enable
 26: end
 27:     

I can restart the service manually on the machine with

service nginx restart
Redirecting to /bin/systemctl restart nginx.service

How to restart nginx service via chef if Systemctl manage the nginx service ?

Should I also create init.d script ?

Thanks

Upvotes: 1

Views: 1474

Answers (1)

coderanger
coderanger

Reputation: 54211

To copy this down to an answer:

That would do it, that predates the automatic systemd support. I don't remember if we even included systemd support at all back then. Probably best to upgrade to at least the latest 11.x release, though really you should move to 12 by now

You can try adding provider Chef::Provider::Service::Systemd to your service resource and see if that works. If it doesn't, then you'll need to upgrade.

Upvotes: 2

Related Questions