【问题标题】:Error executing action `start` on resource 'service[nginx]'对资源“服务 [nginx]”执行操作“启动”时出错
【发布时间】:2014-12-17 22:39:36
【问题描述】:

我正在尝试使用 yum cookbook 作为依赖项在 AMI 机器上安装 nginx。

这就是我的 nginx/recipe/default.rb 的样子,

include_recipe "yum"


yum_repository 'epel' do
    mirrorlist 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=$basearch'
    description 'Extra Packages for Enterprise Linux 7 - $basearch'
    enabled true
    gpgcheck true
    gpgkey 'https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7'
end

yum_repository "nginx" do
    name 'nginx_repo'
    baseurl  'http://nginx.org/packages/rhel/7/$basearch/'
    enabled true
    gpgcheck true
    #gpgkey      'http://nginx.org/keys/nginx_signing.key'
    action :create
end


package "nginx" do

      action :install
end


template "nginx.conf" do
      source "nginx.conf.erb"
      path "#{node['nginx']['dir']}/nginx.conf"
      action  :create
      mode 0644
end


template "default.conf" do
      source "default.conf.erb"
      path "#{node['nginx']['dir']}/conf.d/default.conf"
      action :create
      mode 0644
end


service 'nginx' do
      #supports :restart => :true
      action [:enable, :start]
end

另外,我在 metadata.rb 中添加了 'depends "yum"'

尝试在客户端服务器上运行“sudo chef-client”时,我收到以下错误:

[2014-12-17T08:53:03+00:00] WARN: 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

````
# Verify all HTTPS connections (recommended)
ssl_verify_mode :verify_peer

# OR, Verify only connections to chef-server
verify_api_cert true
````

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

```
knife ssl check -c /etc/chef/client.rb
```

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Starting Chef Client, version 11.16.4
resolving cookbooks for run list: ["yum", "nginx"]
Synchronizing Cookbooks:
  - nginx
  - yum
Compiling Cookbooks...
Converging 7 resources
Recipe: yum::default
* yum_globalconfig[/etc/yum.conf] action create
* template[/etc/yum.conf] action create (up to date)
 (up to date)
Recipe: nginx::default
* yum_repository[epel] action create
* template[/etc/yum.repos.d/epel.repo] action create (up to date)
* execute[yum-makecache-epel] action nothing (skipped due to action :nothing)
* ruby_block[yum-cache-reload-epel] action nothing (skipped due to action :nothing)
 (up to date)
* yum_repository[nginx_repo] action create
* template[/etc/yum.repos.d/nginx_repo.repo] action create (up to date)
* execute[yum-makecache-nginx_repo] action nothing (skipped due to action :nothing)
* ruby_block[yum-cache-reload-nginx_repo] action nothing (skipped due to action :nothing)
 (up to date)
* package[nginx] action install (up to date)
* template[nginx.conf] action create (up to date)
* template[default.conf] action create (up to date)
* service[nginx] action enable (up to date)
* service[nginx] action start

================================================================================
Error executing action `start` on resource 'service[nginx]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service nginx start ----
STDOUT: Starting nginx: [FAILED]
STDERR: nginx: [emerg] invalid log level "pid" in /etc/nginx/nginx.conf:5
---- End output of /sbin/service nginx start ----
Ran /sbin/service nginx start returned 1

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

 53: service 'nginx' do
 54:   #supports :restart => :true
 55:   action [:enable, :start]
 56: end
 57: 

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/nginx/recipes/default.rb:53:in `from_file'

service("nginx") do
  action [:enable, :start]
  supports {:restart=>false, :reload=>false, :status=>true}
  retries 0
  retry_delay 2
  guard_interpreter :default
  service_name "nginx"
  enabled true
  pattern "nginx"
  cookbook_name "nginx"
  recipe_name "default"
end


Running handlers:
[2014-12-17T08:53:05+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-12-17T08:53:05+00:00] ERROR: Exception handlers complete
[2014-12-17T08:53:05+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

Chef Client failed. 0 resources updated in 2.259546529 seconds

[2014-12-17T08:53:05+00:00] ERROR: service[nginx] (nginx::default line 53) had an error:      Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service nginx start ----
STDOUT: Starting nginx: [FAILED]
STDERR: nginx: [emerg] invalid log level "pid" in /etc/nginx/nginx.conf:5
---- End output of /sbin/service nginx start ----
Ran /sbin/service nginx start returned 1
[2014-12-17T08:53:05+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited  unsuccessfully (exit code 1)

【问题讨论】:

    标签: nginx chef-infra chef-recipe cookbook


    【解决方案1】:

    我认为日志很清楚:

    STDERR: nginx: [emerg] invalid log level "pid" in /etc/nginx/nginx.conf:5

    您的 nginx.conf.erb 文件存在问题,因为它写入 log_level = pid 而不是 info/error。

    【讨论】:

    • 我是 CHEF 和​​自己编码的新手,现在我需要在我的食谱中添加几行以获得 ssl 证书 请问您能否帮我编写代码以在 nginx 上创建 ssl 证书和密钥食谱并帮我把它放在下面提到的位置:default['nginx']['ssl_certificate'] = '/etc/nginx/ssl/nginx.crt'default['nginx']['ssl_certificate_key']='/etc/nginx/ssl/nginx.key'
    • 已经有管理证书的食谱了,我在手机上没有链接,午饭后会尽力为您指出正确的方向。但是为此打开一个新问题,因为它相当广泛
    • 我检查了 nginx 食谱,它有太多我不需要的东西,我想简单地在各自的位置安装 ssl 文件。不管怎样,享受你的午餐吧,我会为此提出一个问题。感谢您的帮助
    • 你最终可能会从中得到灵感:github.com/gchef/nginx-cookbook/blob/master/recipes/…supermarket.chef.io/cookbooks?utf8=%E2%9C%93&q=cert 上有很多关于证书的食谱,但我没有使用它们,所以我不知道。跨度>
    • 如果您是 Chef 和一般编码的新手,您真的应该使用社区食谱。你会为自己省去很多痛苦。或者,聘请顾问为您执行此操作。我们很乐意在 SO 上提供帮助,但是通过 SO 问题要求我们为您写食谱有点过​​分,尤其是当我们已经写好并把它们放在超市供您使用时。
    【解决方案2】:

    这与厨师没有太大关系。重要的细节是:

    nginx: [emerg] /etc/nginx/nginx.conf:5 中的无效日志级别“pid”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      • 2015-01-26
      • 2015-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      相关资源
      最近更新 更多