- From: Juanje Ojeda Croissier <
>
- To: chef <
>
- Subject: [chef] Re: Re: Re: Re: Re: Chef Recipe inserting a line before last line in fie
- Date: Tue, 11 Dec 2012 01:03:00 +0000
On Mon, Dec 10, 2012 at 8:44 PM, Arnold Krille
<
>
wrote:
>
On Mon, 10 Dec 2012 04:14:11 +0000 Juanje Ojeda Croissier
>
<
>
>
wrote:
>
> As I had a similar problem time ago, i did create a similar cookbook
>
> (which is also at the community site and be installed from there):
>
>
>
> https://github.com/juanje/cookbook-conf
>
>
>
> There are some examples about how to use this LWRP. Maybe one of them
>
> fit your needs.
>
> I have one action that append a line just after specific line, but not
>
> to prepend, but I could add this action easily if is needed.
>
>
>
> It's something to be used just if is really no way to use a template,
>
> it tries to be as much idempotence as it can.
>
>
Oh, this is nice! I did create something similar but much simpler for
>
appending lines and just used some shell magic.
>
>
With your LWRP, what happens in :insert_after_match when the line to be
>
inserted is already present? Or is this best catched with a not_if
>
-entry?
>
Ouch, good point. It doesn't control that case :-/ But it should. I
think I will review it. Long time since I did it.
This was reusing the Chef lib 'FileEdit', but this is a bit limited
and maybe is worth to change it.
https://github.com/opscode/chef/blob/master/lib/chef/util/file_edit.rb
By now it's probably good idea to use the 'not_if'.
>
I think I will test your recipe the next days.
>
Tell me if you find anything else and I will change it.
Thanks :-)
--
Juanje
http://about.me/juanje
Archive powered by MHonArc 2.6.16.