Chef Kitchen Converge:在 Ubuntu 上安装 apache2 失败

Chef Kitchen Converge: Installing apache2 on Ubuntu fails

设置

我在厨师测试厨房遇到了一些奇怪的问题。我使用了一个非常基本的案例,我尝试在 2 个平台上安装和 运行 Apache。

driver:
  name: vagrant

provisioner:
  name: chef_zero
  always_update_cookbooks: true

verifier:
  name: inspec

platforms:
  - name: centos-6.7
  - name: ubuntu-16.04

suites:
  - name: default
    run_list:
      - recipe[httpd::default]
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes:

reccipe(属性)检测包安装平台:

case node['platform']
when 'ubuntu'
  default['httpd']['package_name'] = 'apache2'
else
  default['httpd']['package_name'] = 'httpd'
end

安装本身基于默认操作: 包节点['httpd']['package_name']

厨房执行

kitchen test 适用于 CentOS。

但是在 Ubuntu 我在 kitchen converge 阶段得到一个错误:

-- Begin output of ["apt-get", "-q", "-y", "install", "apache2=2.4.18-2ubuntu3.3"] ----
   STDOUT: Reading package lists...
   Building dependency tree...
   Reading state information...
   The following additional packages will be installed:
     apache2-bin apache2-data apache2-utils libapr1 libapru til1
     libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 ssl-cert
   Suggested packages:
     www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom
     openssl-blacklist
   The following NEW packages will be installed:
     apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
     libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 ssl-cert
   0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
   Need to get 1560 kB of archives.
   After this operation, 6432 kB of additional disk space will be used.
   Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libapr1 amd64 1.5.2-3 [86.0 kB]
   Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1 amd64 1.5.4-1build1 [77.1 kB]
   Get:3 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-dbd-sqlite3 amd64 1.5.4-1build1 [10.6 kB]
   Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-ldap amd64 1.5.4-1build1 [8720 B]
   Get:5 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 liblua5.1-0 amd64 5.1.5-8ubuntu1 [102 kB]
   ...

当我查看 us.archive.ubuntu.com 网站时,找不到请求的二进制文件。所以安装失败是合乎逻辑的。我真的不知道 apache2=2.4.18-2ubuntu3.3 在哪里定义。有人知道吗?有人遇到过类似的问题吗?

非常感谢。 干杯,托马斯

您可能需要 apt-get update,因为图像中的 apt 缓存文件已过时。我们有 apt_update 资源可以为您处理。