[chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: where is the better place for this code?


Chronological Thread 
  • From: Juan Jesús Ojeda Croissier < >
  • To:
  • Cc:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: where is the better place for this code?
  • Date: Thu, 17 Nov 2011 19:11:27 +0100

On Thu, Nov 17, 2011 at 6:41 PM, John E. Vincent (lusis)
< >
 wrote:
> 2011/11/17 Juan Jesús Ojeda Croissier 
> < >:
> <snip>
>>> Chef already has code for this: 
>>> https://github.com/opscode/chef/blob/master/chef/lib/chef/util/file_edit.rb
>>>
>>> That said, you really should do whatever you can to avoid using 
>>> search/replace.
>>>
>>
>> Hummm... I'm curious... why's that?
>>
>> BTW, thanks for the link :-)
>>
>
> The proper path is to manage the file with Chef (as a template) or
> move the setting/line it needs somewhere that Chef can manage.
>
> Search and replace is fragile.
>
> Depending on the type of file, you can:
>
> - substitute an environment variable sourced from a file that Chef DOES 
> manage.
> - include another file that chef manages at the head of the file that
> needs the setting
> - merge the contents of that file with another file that chef manages
> as part of the recipe
> - move the setting out of that file into some sort of configuration 
> repository
>

I see... but I'm not sure that none of those are my case. I'll show
you a real example to see if it could be done with one of those
approach:

I need to be sure that the homepage for the Firefox on all the nodes
(Ubuntu based clients) I'm managing with Chef are always the same. The
homepage is defined (after the user launch the first time the Firefox)
at the home: /home/user/.mozilla/firefox/profile/prefs.js

There are some configurations defined like this:
...
user_pref("browser.rights.3.shown", true);
user_pref("browser.startup.homepage", "http://www.google.com";);
user_pref("browser.startup.homepage_override.buildID", "20111008085652");
user_pref("browser.startup.homepage_override.mstone", "rv:7.0.1");
...

At my organization I can let the users change others configurations,
but the homepage, so I want to change just that, no using a template
or new file to overwrite the file.

That's why search and replace sounded a good option for me. And this
is just one of the similar files I have to manage in a similar way.
I guess I could try the merge as you said for some of them, but I
don't think that I could for all.

But maybe I didn't get well all the options you give me, it's very
possible. Or I'm missing something at my problem.
Anyway, all the responses are being very enlighten for me, I start to
understand better the whole picture (I think)

Thanks :-)

-- 
Juanje



Archive powered by MHonArc 2.6.16.

§