使用厨师删除 ubuntu 包

Leo*_*opd 0 ubuntu chef apt

较旧版本的食谱安装了一个我不再需要在我的系统上的软件包。我的理解是,chef 没有一种直接的方法来明确删除一个包,所以我使用了以下的钝锤execute

execute "Remove nasty perl gearman-server" do
    command "apt-get -y remove gearman-server"
    ignore_failure true
end
Run Code Online (Sandbox Code Playgroud)

但这失败了,我猜是因为厨师本身对 dpkg 有锁定?

STDERR: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
Run Code Online (Sandbox Code Playgroud)

我怎样才能以编程方式确保这个包不再在我的机器上?如果不清楚,我对仅限 ubuntu 的解决方案非常满意。

Tim*_*ter 5

Chef包资源允许以独立于发行版的方式移除或清除包:

package "gearman-server" do
  action :remove
end
Run Code Online (Sandbox Code Playgroud)

如果安装了该程序包,此代码将删除该程序包,如果未安装该程序包,则不执行任何操作。