运行烹饪书后,httpd的安装是没有得到完成

时间:2019-01-29 10:29:56

标签: chef httpd.conf chef-recipe

我写厨师配方安装httpd和启用和启动相同的。但出现以下错误。

Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * apt_package[httpd] action install

    ================================================================================
    Error executing action `install` on resource 'apt_package[httpd]'
    ================================================================================

    Chef::Exceptions::Package
    -------------------------
    httpd is a virtual package provided by multiple packages, you must explicitly select one

    Resource Declaration:
    ---------------------
    # In server.rb

      6: package 'httpd' do
      7:        action :install
      8: end
      9: 

    Compiled Resource:
    ------------------
    # Declared in server.rb:6:in `run_chef_recipe'

    apt_package("httpd") do
      package_name "httpd"
      action [:install]
      default_guard_interpreter :default
      declared_type :package
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
    end

    System Info:
    ------------
    chef_version=14.8.12
    platform=ubuntu
    platform_version=18.04
    ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
    program_name=/usr/bin/chef-apply
    executable=/opt/chefdk/bin/chef-apply

[2019-01-29T10:14:30+00:00] FATAL: Stacktrace dumped to /home/devopsdevops95/.chef/cache/chef-stacktrace.out
[2019-01-29T10:14:30+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-01-29T10:14:30+00:00] FATAL: Chef::Exceptions::Package: apt_package[httpd] ((chef-apply cookbook)::(chef-apply recipe) line 6) had an error: Chef::Exceptions::Package: httpd is a virtual package provided by multiple packages, you must explicitly select one

我在运行配方之前尝试了许多解决方案,例如apt-get update,但没有用。

chef -v
Chef Development Kit Version: 3.6.57
chef-client version: 14.8.12
delivery version: master (5fb4908da53579c9dcf4894d4acf94d2d9ee6475)
berks version: 7.0.7
kitchen version: 1.24.0
inspec version: 3.2.6

OS -
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"

package 'httpd' do
        action :install
end

file '/var/www/html/index.html' do 
        content '<h1>Hello, world!</h1>'
end

service 'httpd' do

我希望它可以安装httpd没有任何问题。

2 个答案:

答案 0 :(得分:0)

您是否尝试定义apt_preference资源? https://docs.chef.io/resource_apt_preference.html

apt_preference资源允许创建APT首选项文件。首选项文件用于控制在安装过程中优先考虑哪些软件包版本和源。

答案 1 :(得分:0)

最后我完成了。

  1. httpd烹饪书已不再使用-https://supermarket.chef.io/cookbooks/httpd
  2. 我使用了以下食谱
execute 'sudo apt-get update' do
  command 'sudo apt-get update'
end

apt_package 'apache2' do
  action :install
end

file '/var/www/html/index.html' do
  content '<h1>Hello, World!</h1>'
end

service 'apache2' do 
  action [:enable, :start]
end