在资源包[nginx]上执行操作安装时出错
我正在尝试使用yum cookbook作为依赖项在ec2服务器上安装nginx 这就是我的nginx/recipe/default.rb的样子在资源包[nginx]上执行操作安装时出错,nginx,amazon-ec2,chef-infra,cookbook,Nginx,Amazon Ec2,Chef Infra,Cookbook,我正在尝试使用yum cookbook作为依赖项在ec2服务器上安装nginx 这就是我的nginx/recipe/default.rb的样子 include_recipe "yum" package "nginx" do version "1.6.2" action :install end template "nginx.conf" do source "nginx.conf.erb" path "#{node['nginx']['dir']}/nginx.conf" act
include_recipe "yum"
package "nginx" do
version "1.6.2"
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-site.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"
尝试在客户端ec2服务器上运行以下命令时
sudo chef-client
我得到以下错误:
[2014-12-15T01:38:31-05: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.
要解决此问题,请在配置文件中添加如下条目:
# Verify all HTTPS connections (recommended)
ssl_verify_mode :verify_peer
# OR, Verify only connections to chef-server
verify_api_cert true
要检查SSL配置或排除错误,可以使用
检查
命令如下:
knife ssl check -c /etc/chef/client.rb
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Starting Chef Client, version 11.16.4
resolving cookbooks for run list: ["yum", "nginx"]
Synchronizing Cookbooks:
- yum
- nginx
Compiling Cookbooks...
Converging 5 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
* package[nginx] action install
================================================================================
Error executing action `install` on resource 'package[nginx]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from rhui-REGION-rhel-server-releases: [Errno 256] No more mirrors to try.
https://rhui2-cds01.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
https://rhui2-cds02.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/nginx/recipes/default.rb
13: package "nginx" do
14: version "1.6.2"
15: action :install
16: end
17:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/nginx/recipes/default.rb:13:in `from_file'
package("nginx") do
action [:install]
retries 0
retry_delay 2
guard_interpreter :default
package_name "nginx"
version "1.6.2"
timeout 900
cookbook_name "nginx"
recipe_name "default"
end
Running handlers:
[2014-12-15T01:38:33-05:00] ERROR: Running exception handlers
Running handlers complete
[2014-12-15T01:38:33-05:00] ERROR: Exception handlers complete
[2014-12-15T01:38:33-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.604475896 seconds
[2014-12-15T01:38:33-05:00] ERROR: package[nginx] (nginx::default line 13) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from rhui-REGION-rhel-server-releases: [Errno 256] No more mirrors to try.
https://rhui2-cds01.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
https://rhui2-cds02.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.16.4/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1
[2014-12-15T01:38:33-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
根据这句话:
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from rhui-REGION-rhel-server-releases: [Errno 256] No more mirrors to try.
https://rhui2-cds01.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
https://rhui2-cds02.us-east-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7.0-1.el7/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Yum在访问存储库时遇到问题。似乎yum配置是错误的。
您可以使用一个简单的
yum install nginx
进行测试,看看这是否真的是一个与chef相关的问题(在本例中,更新问题)或者,如果只是您的系统没有正确注册/配置rhn。您是否介意格式化您的文本以使其可读?您不使用community nginx cookbook的具体原因是什么?这项工作做得相当不错。@TejayCardon我希望在不使用社区nginx cookbook中列出的非常复杂的配置的情况下配置我自己的测试配方。我现在只想创建两个模板文件。@StephenKing是的,我很乐意,先生,您能突出显示您不清楚的部分吗?谢谢@coderanger,因为我尝试了“Yum安装nginx”,看起来RHN有问题,[link]