- From: Mike <
>
- To: "
" <
>
- Subject: [chef] Re: Re: Question - only if your configuration files are changed
- Date: Thu, 7 Feb 2013 09:27:46 -0500
If you're interested in the internals, here's the code (for Chef 11,
although I don't think it changed significantly since Chef 10).
https://github.com/opscode/chef/blob/master/lib/chef/provider/template.rb#L51-L76
https://github.com/opscode/chef/blob/master/lib/chef/provider/file.rb#L275-L302
The 'template' provider inherits the 'file' provider and uses the
'backup' method from 'file'.
-M
On Thu, Feb 7, 2013 at 9:19 AM, Spike Grobstein
<
>
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.