While this is kind of kludg-y, might you try building the multipart
file with Puppet itself:

http://reductivelabs.com/trac/puppet/wiki/Recipes/BuildingMultipartFiles

It's useful for building files where you have chunked sections and, of
course, you can use templates etc... where necessary.

I have no idea what it does to performance though.

Trevor

On Fri, May 15, 2009 at 14:41, Rob McBroom <mailingli...@skurfer.com> wrote:
>
> I haven't seen this really discussed in the wiki or on the list. I
> suspect anyone with enough knowledge to help me can already tell where
> I'm going from the subject, but here's a lengthy description of the
> problem anyway…
>
> For files like sshd_config or Postfix's main.cf, using Augeas is very
> straightforward. You have a bunch of unique keys, you set the values
> for the ones you care about, Puppet can tell what does and does not
> need to be changed and you get on with your life.
>
> However, what seems like a majority of files are broken up into an
> "array" of values. Take the `/etc/exports` [example from the wiki][1].
> Existing items are assigned numbers 1-4 by Augeas when the file is
> loaded. If you add an item with an index of 10000, the tree will
> contain items 1, 2, 3, 4 and 10000 until you save the changes. But on
> the next Puppet run, Augeas will load the file and number the items
> 1-5. There won't be an item 10000, so what's to stop it from being
> added over and over again on every run? The same can be said for
> inserting things. Say I want to insert something after /2 in `/etc/
> inittab`. There will be a /2 in the tree on every single run, so
> what's to stop it from inserting again and again?
>
> I guess what I'm getting at is that the Augeas type seems extremely
> whatever-the-opposite-of-idempotent-is by default. Or at least it's
> very easy for a person to accidentally make a mess.
>
> I realize the numbering of items in certain files is unavoidable, but
> is there a good way to handle these situations in Puppet? Here are
> some real-world examples from my manifests that seem to work.
>
>     # adds rh:06:wait:/etc/rc.shutdown
>     augeas { "shutdown":
>       require => File["shutdown"],
>       context => "/files/etc/inittab",
>       changes => [
>         "ins 3 after 2",
>         "set 3[1]/id rh",
>         "set 3[1]/runlevels 06",
>         "set 3[1]/action wait",
>         "set 3[1]/process /etc/rc.shutdown",
>       ],
>       onlyif => "get 3/id != rh",
>     }
>
> This inserts a line after the `/etc/rc.d/rc.sysinit` line. Works fine
> now, but what if the sysinit line isn't item 2 in every future version
> of the OS? Maybe I could add "only if 2's id is 'si'" to make sure,
> but what if it's *not* 'si'? It won't get added to the wrong place,
> but it won't get added anywhere else either. Clearly not what I'm
> shooting for.
>
>     # boot systems to runlevel 3
>     augeas { "runlevel":
>       context => "/files",
>       changes => [
>         "set /etc/inittab/1/runlevels 3",
>       ],
>       onlyif => "get /etc/inittab/1/action == initdefault",
>     }
>
> Again, this works, but what if initdefault was *not* item 1? I've
> prevented the wrong thing from happening, but I haven't ensured the
> right thing. (By the way, why are items numbered in inittab when they
> all have an "id"?)
>
> On a related note, there doesn't seem to be a good way to add comments
> to a particular spot to explain the changes you've made. This is true
> even for the "straightforward" files mentioned above. Any advice?
>
> Please view this as a question and not a complaint. If I didn't think
> Augeas and its Puppet type were awesome, I wouldn't have tried to use
> them heavily enough to encounter the above. Thanks.
>
> [1]: http://reductivelabs.com/trac/puppet/wiki/PuppetAugeas
>
> --
> Rob McBroom
> <http://www.skurfer.com/>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to