【问题标题】:Restart Nginx service on Centos 7 via chef通过 Chef 在 Centos 7 上重启 Nginx 服务
【发布时间】:2016-06-26 10:22:48
【问题描述】:

我正在尝试使用 chef 配置 nginx 服务,但出现以下错误。

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:     

我可以在机器上手动重启服务

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

如果 Systemctl 管理 nginx 服务,如何通过 chef 重启 nginx 服务?

我还应该创建 init.d 脚本吗?

谢谢

【问题讨论】:

  • 什么版本的厨师?它应该在运行输出的顶部告诉您版本。
  • 启动 Chef 客户端,版本 11.8.2
  • 可以做到,早于自动 systemd 支持。我不记得当时我们是否甚至包括了 systemd 支持。可能最好至少升级到最新的 11.x 版本,但实际上您现在应该升级到 12。

标签: nginx chef-infra cookbook


【解决方案1】:

将其复制到答案中:

这样就可以了,这早于自动 systemd 支持。我不记得当时我们是否甚至包括了 systemd 支持。可能最好至少升级到最新的 11.x 版本,但实际上您现在应该升级到 12

您可以尝试将provider Chef::Provider::Service::Systemd 添加到您的service 资源中,看看是否可行。如果没有,那么您需要升级。

【讨论】:

    猜你喜欢
    • 2016-04-29
    • 2020-10-21
    • 2020-07-12
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 2016-07-28
    • 2018-06-21
    • 1970-01-01
    相关资源
    最近更新 更多