在资源'上执行操作“start”时出错;服务[nginx]和#x27;

在资源'上执行操作“start”时出错;服务[nginx]和#x27;,nginx,chef-infra,chef-recipe,cookbook,Nginx,Chef Infra,Chef Recipe,Cookbook,我正在尝试在AMI机器上安装nginx,并使用yum cookbook作为依赖项 这就是我的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 E

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

这就是我的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中添加了“依赖于”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:[emerg]在/etc/nginx/nginx.conf:5中的日志级别“pid”无效


日志很清楚,我认为:

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


您的nginx.conf.erb文件在某种程度上是一个问题,因为它写入了一个log_level=pid而不是info/error。

我是CHEF的新手,自己编写代码,现在我需要为ssl证书在我的食谱中添加几行代码。我可以知道您是否可以帮助我在nginx食谱中创建ssl证书和密钥,并帮助我将其放置在下面提到的位置:
default['nginx']['ssl\u certificate']='/etc/nginx/ssl/nginx.crt'
default['nginx']['ssl\U证书\U密钥']='/etc/nginx/ssl/nginx.key'
已经有了管理证书的食谱,我在电话上没有链接,午餐后会尝试为您指出正确的方向。但这是一个新的问题,因为它非常庞大。我检查了nginx食谱,它有太多我不需要的东西,我只想在各自的计算机上安装ssl文件地点。无论如何,享受你的午餐吧,我会为此提出一个问题。我感谢你的帮助。你最终可能会从这本书中得到灵感:有很多烹饪书是关于证书的,但我没有使用它们,所以我说不清。如果你对厨师和编码都是新手,你真的应该使用社区烹饪书。哟你会为自己省去很多痛苦。或者,请一位顾问为你做这件事。我们很乐意在这方面提供帮助,但让我们通过SO问题为你写烹饪书有点太多了,特别是当我们已经写了并把它们放在超市供你使用的时候。