Search code examples
chef-infrachef-recipe

Chef template resource notifies on every run


I've got the following snippet in a recipe:

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

The problem is that the bash action is run every time, even when the config doesn't change:

$ 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

So the config stayed the same, but the action was called nonetheless. How do I fix this?


Solution

  • Apparently the file owner changed to 0 as revealed by the -l debug flag. The contents of the file indeed stayed the same.