[chef] Re: Re: Re: Question - only if your configuration files are changed


Chronological Thread 
  • From: Joshua Timberman < >
  • To: < >
  • Subject: [chef] Re: Re: Re: Question - only if your configuration files are changed
  • Date: Thu, 7 Feb 2013 23:29:45 -0700

The checksum of the rendered file content and target file is SHA256, specifically. 

--
Joshua Timberman

On Thursday, February 7, 2013 at 8:17, Jesse Campbell wrote:

essentially it generates a new file, generates an MD5-like hash of the file, and compares that to the MD5-like hash of the existing file, and if changed update and notify.

internally, it may generate the MD5-like hash against a raw string, rather than writing it out to a file first, but that depends on which resource is being used.
"remote_file", for example, generally fetches the remote into a local tempfile and takes the hash of that. "template" and "file" generally work from the generated string, cookbook_file already knows the hash because it was generated when uploading the cookbook to the chef server... there are more.


On Thu, Feb 7, 2013 at 9:19 AM, Spike Grobstein < " target="_blank"> > wrote:
Interesting.

So how do the internals of this work? Does chef generate a new output file in a temp folder, compare the new file to the old file, then if they differ, update and notify?

I was always under the impression that this would notify every single time, so I was incredibly apprehensive about doing this on our postgres and redis production servers.

Thanks for the info. You've seriously just simplified my life.



...spike

On Feb 7, 2013, at 9:06 AM, Mike wrote:

> +1 to Thom.
>
> Spike - Since Chef keeps some backups around of previous version in
> /var/cache/chef typically (you can also see the filename in a chef run
> with debug where something changes), there's no need to timestamp your
> file.
> Also, leveraging filesytem mtime to see when a file was changed is useful.
>
> If you were statically entering a date/time of an Operator change -
> say, add "2013-02-07 Mike added a new gadget" to your file as a
> changelog, that might be useful, but also might be more effort than
> it's worth - that stuff typically lives in our source control history
> anyways.
>
> -M
>
> On Thu, Feb 7, 2013 at 9:03 AM, Thom May < "> > wrote:
>> note that if you put a timestamp in the template, you'll get a notification
>> every time, since chef will update the timestamp every time it runs.
>>
>>
>> On Thu, Feb 7, 2013 at 1:33 PM, Spike Grobstein < "> >
>> wrote:
>>>
>>> I've often wondered this myself. I currently keep one backup of the config
>>> and restart only if the current and the backup differ, but its incredibly
>>> hacky and doesn't work if you put a "configured by chef" time stamp at the
>>> top.
>>>
>>> It doesn't appear that that recipe only restarts if the file is changed.
>>> Or am I missing something?
>>>
>>>
>>>
>>> ...spike
>>> (Sent via handheld, please pardon spelling errors)
>>>
>>> On Feb 7, 2013, at 8:18 AM, Mike < "> > wrote:
>>>
>>>> See here, from the opsocde ntp cookbook:
>>>>
>>>> https://github.com/opscode-cookbooks/ntp/blob/master/recipes/default.rb#L44-L50
>>>>
>>>> On Thu, Feb 7, 2013 at 6:50 AM, Alex Vitola < "> >
>>>> wrote:
>>>>> How do I restarting a service only if your configuration files are
>>>>> changed
>>>>>
>>>>>
>>>>> Example: ntp service
>>
>>






Archive powered by MHonArc 2.6.16.

§