配方没有在Chef中执行

时间:2012-11-12 12:05:59

标签: chef apt recipe cookbook

我正在制作一个简单的配方,以便升级整个系统。

include_recipe "apt"

execute "apt-get upgrade -y" do
        command "apt-get upgrade -y"
        action :nothing
end

但它永远不会运行:

chef-solo -j node.json -W

Recipe: up2date::default
  * execute[apt-get upgrade -y] action nothing[2012-11-12T13:05:04+01:00] 
    INFO: Processing execute[apt-get upgrade -y] 
    action nothing (up2date::default line 12)  (up to date)

无法理解为什么?

有更好/更清洁的方式吗?

1 个答案:

答案 0 :(得分:3)

如果您要包含“apt”配方,则无需创建执行[apt-get upgrade -y] 资源。或者,如果您不想包含“apt”配方,请使用

execute "apt-get upgrade -y" do
    command "apt-get upgrade -y"
    action :run
end

但是,由于run是默认操作,name是默认命令,因此可以缩短为

execute "apt-get upgrade -y"