[chef] Re: Notification on template change


Chronological Thread 
  • From: oscar schneider < >
  • To:
  • Subject: [chef] Re: Notification on template change
  • Date: Tue, 14 Feb 2012 03:50:50 +0100

Hi Steffen,

usually the :create action is what you want; if the rendered content of the template equals the content of the destination file, Chef should not "recreate" the file (check for access timestamps), thus the notifies will only be run when the content differs (i.e. you change an attribute that is used in the template or change the template file itself). 

At least that is what I was believing and hoping :)

If this is not the case I either misunderstood a lot of my services/cookbooks or my infrastructure should've gone to hell a long time ago :)

Regarding the OTRS cookbook, I'll let a coworker know, and also check it out myself. My perl is pretty bad but my chef is decent (at least imo). 

Have you considered writing an upgrade.rb recipe which would incrementally update from a pretty old version to the most recent one or something like this? If I understood it correctly OTRS offers no direct upgrade paths from e.g. 2.2 => 3.0 but instead you have to install 2.3, then 2.4 and so on.

Cheers,

Oscar


On Mon, Feb 13, 2012 at 8:10 PM, Steffen Gebert < "> > wrote:
Hi list,

I'm searching for a way to notify another resource, as soon as a template changed:

template "foo.conf" do
 source "foo.conf.erb"
 notfies :run, "execute[rebuildConfig]"
end

(see this recipe [1]).

When using the create_if_missing action, it's only created once, but not as soon as I upload a cookbook with a changed version of the config file.
With the create action, the resource is notified every time (which flushes caches, regenerates merged config files etc..).

Is there a way in between? Notify, if the old and the new file differ?

Thanks for your help!
Steffen

[1] https://github.com/StephenKing/chef-cookbook-otrs/blob/master/recipes/default.rb#L175

P.S: It would be great, if one wants to review the OTRS cookbook - it still has some minor issues (and probably misses some best-practices)






Archive powered by MHonArc 2.6.16.

§