【问题标题】:"sudo chef-client" failed in Amazon Linux EC2 server“sudo chef-client”在 Amazon Linux EC2 服务器中失败
【发布时间】:2016-01-25 23:35:12
【问题描述】:

下面是“主厨-客户”的错误信息:

它说食谱 apt is missing ,但是当我使用 knife cookbook list 检查厨师服务器中的食谱列表时,我看到了 apt 食谱。请帮我。我已经部署了 apache2 cookbook ,现在更改了节点中 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 中失败了。那么这里可能是什么问题? 使用测试厨房,我可以成功部署在 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

【问题讨论】:

  • 您是否向厨师服务器上传或下载了 apt 食谱?
  • 使用 berks ,我已经上传了所有依赖的说明书,使用“Berks install and berks upload”命令
  • 我在 Redhat linux 中手动执行了“yum update”命令,然后重新运行“Chef-client”命令。但仍然出现同样的错误。

标签: chef-infra chef-recipe


【解决方案1】:

我认为你不是在使用官方的 apache2 食谱,而是创建自己的来学习。

您需要在 metadata.rb 中包含 apt 食谱作为依赖项:

# metadata.rb
depends 'apt', '~> 2.9'

请注意,除了学习厨师,您应该使用官方的httpdapache2 食谱,而不是自己创建。

更新:

Chef::Exceptions::Package: No candidate version available for php-devel

您正在使用的php 食谱正在尝试安装php-devel 软件包。但是这个包在你在 EC2 上使用的发行版中不存在。

尝试使用与test-kitchen 测试的操作系统和分发版本相同的 EC2 AMI。

您使用的 php 食谱版本似乎不支持您在 EC2 上使用的操作系统。

更新 2:

您使用的某些说明书可能不支持 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

【讨论】:

  • 我已经添加了 apt :名称 'wordpress' 维护者 'rajkumar' 维护者电子邮件 'you@example.com' 许可证 'all_rights' 描述 '安装/配置 wordpress' long_description '安装/配置 wordpress' 版本' 0.6.0' 依赖 'apt' 依赖 'php' 依赖 'openssl' 依赖 'apache2' 依赖 'database' 依赖 'mysql' 依赖 'mysql2_chef_gem','~> 1.0.1' 依赖 'build-essential' 依赖 'iis'依赖'tar' 依赖'nginx', '~> 2.7.4' 依赖'php-fpm' 依赖'selinux', '~> 0.7'
  • 问题依然存在,请查看更新后的问题区
  • 感谢@Zuazo,我认为一些食谱可能与少数 EC2 AMI 存在可比性问题。
  • github.com/test-kitchen/kitchen-ec2 我认为只包含 CentOS、Ubuntu 和 Widows Server。 Amazon linux 可能无法与 AWS EC2 Kitchen 一起使用。但是 Community CentOS 将在我可以使用的 EC2 AMI 列表中提供。再次感谢您。
  • @Rajkumar 目前我使用这种方法在 Amazon Linux 上测试我的食谱。事实上,许多官方食谱使用这种方法在 Amazon Linux 上进行测试,例如 chef-client。但是,当然,并不是所有的食谱都支持这种分布。
猜你喜欢
  • 2013-05-08
  • 1970-01-01
  • 2020-10-29
  • 2011-11-17
  • 2022-10-22
  • 2021-09-11
  • 2018-09-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多