以下是“chef-client”错误消息:
它说食谱apt
丢失,但是当我使用knife cookbook list
检查厨师服务器中的食谱清单时,我看到了apt
食谱。请帮我。我已经部署了apache2
食谱,现在更改了节点中chef-client的运行列表。
13: service 'apache2' do
14: supports :status => true
15: action [:enable, :start]
16: end
17:
18: template '/var/www/html/index.html' do
Running handlers:
[2016-01-25T07:40:17+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-01-25T07:40:17+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2016-01-25T07:40:17+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-01-25T07:40:17+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-01-25T07:40:17+00:00] ERROR: Cookbook apt not found. If you're loading apt from another cookbook, make sure you configure the dependency in your metadata
[2016-01-25T07:40:17+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
更新:
我可以使用Vagrant在Test Kitchen中成功安装所有的食谱,但我无法在AWS EC2中成功部署。
下面是另一个例子:
default_guard_interpreter :default
package_name "php-devel"
flush_cache {:before=>false, :after=>false}
declared_type :package
cookbook_name "php"
recipe_name "package"
end
Running handlers:
[2016-01-25T09:00:06-05:00] ERROR: Running exception
handlers Running handlers complete
[2016-01-25T09:00:06-05:00] ERROR:
Exception handlers complete Chef Client failed. 0 resources updated in
16 seconds
[2016-01-25T09:00:07-05:00] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[2016-01-25T09:00:07-05:00] FATAL:
Please provide the contents of the stacktrace.out file if you file a
bug report
[2016-01-25T09:00:07-05:00] ERROR: yum_package[php-devel]
(php::package line 59) had an error: Chef::Exceptions::Package: No
candidate version available for php-devel
[2016-01-25T09:00:07-05:00]
FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited
unsuccessfully (exit code 1)
更新2: 我已成功在AWS EC2 Ubuntu 14.04实例中安装了厨师食谱“Wordpress”。但是,在Amazon Linux EC2和Redhat linux EC2中失败了。那么问题可能在这里呢? 使用Test Kitchen,我可以在CentOS中成功部署!但无法在AWS EC2中安装Redhat linux和Amazon Linux。
+ DocumentRoot /var/www/wordpress
+
+ <Directory /var/www/wordpress>
+ Options FollowSymLinks
+ AllowOverride FileInfo Options
+ Require all granted
+ </Directory>
+
+ <Directory />
+ Options FollowSymLinks
+ AllowOverride None
+ </Directory>
+
+ LogLevel info
+ ErrorLog /var/log/apache2/wordpress-error.log
+ CustomLog /var/log/apache2/wordpress-access.log combined
+
+ RewriteEngine On
+</VirtualHost>
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
* execute[a2ensite wordpress.conf] action run
- execute /usr/sbin/a2ensite wordpress.conf
Recipe: apache2::default
* service[apache2] action reload
- reload service service[apache2]
Running handlers:
Running handlers complete
Chef Client finished, 92/168 resources updated in 01 minutes 58 seconds
答案 0 :(得分:1)
我认为您没有使用官方apache2
食谱,而是创建自己的食谱。
您需要将apt
食谱作为依赖项添加到 metadata.rb 中:
# metadata.rb
depends 'apt', '~> 2.9'
请注意,除了学习厨师之外,您应该使用官方的httpd
或apache2
食谱,而不是创建自己的食谱。
Chef::Exceptions::Package: No candidate version available for php-devel
您正在使用的php
食谱正在尝试安装php-devel
包。但是,您在EC2上使用的发行版中不存在此包。
尝试使用与test-kitchen
测试的操作系统和发行版相同的EC2 AMI。
您使用的php
食谱版本似乎不支持您在EC2上使用的操作系统。
您使用的某些烹饪书可能不支持Amazon Linux或您尝试使用的其他发行版。
无论如何,您可以在部署之前使用kitchen-ec2
gem在Amazon Linux上测试您的食谱。
.kitchen.yml 示例:
platforms:
- name: amazon-20XX.YY.ZZ
driver:
name: ec2
image_id: ami-XXXXX # The AMI id of Amazon Linux
instance_type: t1.micro
transport:
username: ec2-user