【问题标题】:Recipe not being executed in Chef食谱未在 Chef 中执行
【发布时间】:2012-10-31 20:37:09
【问题描述】:

我正在制作一个简单的方法,可以通过 apt-get 升级整个系统。

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)

不明白为什么?

有没有更好/更清洁的方法?

【问题讨论】:

    标签: chef-infra apt recipe cookbook


    【解决方案1】:

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

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

    但由于运行是默认操作,名称是默认命令,可以缩短为

    execute "apt-get upgrade -y"
    

    【讨论】:

    • 谢谢;只需执行“apt-get upgrade -y”而不使用“do”块?
    • 你是说“apt”配方会自动运行apt-get upgrade吗?因为它似乎不适合我。
    • 是的,它会的。在您的情况下,您的食谱中的某些内容可能会覆盖资源。我不知道。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 2014-11-06
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    相关资源
    最近更新 更多