在 Ubuntu 18.04 上通过 chef-solo 安装 apache2 失败

apache2 install via chef-solo on Ubuntu 18.04 failing

我试图通过 chef-solo 安装 apache2 失败。当我 运行 本地模式下的 chef-client 时,同样的方法有效。

package 'apache2' do
  action [:$pstall]
end
and 
package 'apache2'

两者都失败了,但有以下例外:

* apt_update[Update the apt cache daily] action periodic (up to date)
* apt_package[apache2] action install

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

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '100'
---- Begin output of ["apt-get", "-q", "-y", "install", "apache2=2.4.29-1ubuntu4.4"] ----
STDOUT:
STDERR: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
---- End output of ["apt-get", "-q", "-y", "install", "apache2=2.4.29-1ubuntu4.4"] ----
Ran ["apt-get", "-q", "-y", "install", "apache2=2.4.29-1ubuntu4.4"] returned 100

事实上 chef-solo 能够执行菜谱中的第一行,这意味着配置应该没问题。我不确定我错过了什么。拜托,不胜感激。

最佳,

爱丽丝

仅供参考,问题已解决

Chef solo 应该 运行 来自 root 用户或使用 sudo。