- From: Juanje Ojeda Croissier <
>
- To:
- Subject: [chef] Re: Re: Re: edit a prop file using chef
- Date: Thu, 14 Jun 2012 19:16:24 +0100
On Thu, Jun 14, 2012 at 6:18 PM, Eric Jain
<
>
wrote:
>
There is no "append these lines if they are not present" function?
>
Yes:
http://rubydoc.info/gems/chef/0.10.10/Chef/Util/FileEdit#insert_line_if_no_match-instance_method
insert_line_if_no_match(regex, newline)
Well, it checks line by line, not a few lines, though.
>
On Thu, Jun 14, 2012 at 7:13 AM, Bryan Baugher
>
<
>
>
wrote:
>
> Chef does not have this functionality directly or in the form of a
>
> resource.
>
> One option could be to read in the file, parse the contents and then output
>
> the 'new' file (with your changes) using a template resource[1]. There are
>
> also things like this[2] in chef that could help.
>
>
>
> Though a Chef purist would probably say that you shouldn't be relying on
>
> configuration already set on the system itself and that you should let chef
>
> control the whole file (chef is the source/messenger of truth). So you
>
> would
>
> either let your cookbook control the file or (if the property file is
>
> outside the scope of your application/cookbook) let the correct cookbook
>
> control the file and provide a means to inject/edit the properties through
>
> that cookbook.
>
>
>
> [1] - http://wiki.opscode.com/display/chef/Resources#Resources-Template
>
> [2] - http://rubydoc.info/gems/chef/0.10.10/Chef/Util/FileEdit
--
Juanje
http://about.me/juanje
Archive powered by MHonArc 2.6.16.