【问题标题】:Chef template resource notifies on every run每次运行时都会通知厨师模板资源
【发布时间】:2013-09-30 22:32:38
【问题描述】:

我的食谱中有以下 sn-p:

template "/mnt/application/config/pusher/#{port}.js" do
    owner "root"
    group "root"

    source "pusher/config.js.erb"
    mode "644"

    variables({
        :directory => metricsDir,
        :host => host
    })

    notifies :run, "bash[restart pusher-#{port}]"
end

bash "restart pusher-#{port}" do
    code "supervisorctl restart pusher-#{port}"
    action :nothing
end

问题是每次都会运行 bash 操作,即使配置没有改变:

$ cp /mnt/application/config/pusher/50000.js ~/pre-run.js
$ chef-client
...
[Fri, 27 Sep 2013 09:49:03 +0000] INFO: template[/mnt/application/config/pusher/50000.js] sending run action to bash[restart pusher-50000] (delayed)
[Fri, 27 Sep 2013 09:49:03 +0000] INFO: Processing bash[restart pusher-50000] action run (shm::add_pusher line 96)
pusher-50000: stopped
pusher-50000: started
...
$ diff /mnt/application/config/pusher/50000.js ~/pre-run.js
$ echo $?
0

所以配置保持不变,但仍然调用了操作。我该如何解决这个问题?

【问题讨论】:

  • 能否给出config.js.erb的内容?您也可以使用调试日志级别运行 chef-client (chef-client -l debug)
  • 那么如果内容没有变化,那么还有什么变化吗?确保所有者、组和文件权限保持不变。
  • 谢谢@kamaradclimber 和@Draco Ater,确实是-l debug 我已经看到所有者正在改变。

标签: chef-infra chef-recipe


【解决方案1】:

显然,-l debug 标志显示文件所有者更改为 0。文件的内容确实保持不变。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 2015-04-02
    相关资源
    最近更新 更多