Question - is it possible to use the puppet regsubst function in place of
the exec used here (to save spawning a new shell process) ?
kevin
On Friday, May 21, 2010 at 10:28:58 PM UTC-4, Marley Bacelar wrote:
>
> Nice... I solved my probleman using the:
>
> define replace($file, $pattern, $replacement) {
> exec { "/usr/bin/perl -pi -e 's/$pattern/$replacement/' '$file'":
> onlyif => "/usr/bin/perl -ne 'BEGIN { \$ret = 1; } \$ret = 0 if
> /$pattern/ && ! /$replacement/ ; END { exit \$ret; }' '$file'",
> }
> }
>
> Then i my class used:
>
> replace { "/etc/bashrc":
> file => "/etc/bashrc",
> pattern => "PS1",
> replacement => "PS1 DOMAINA.COM"
> }
> Worked perfectly... Know i will see the other options proposed here. Thank
> you evry much guys
>
> --
> Marley Bacelar
> Project Fedora Ambassador
> VCP, VSP. VTSP., ITILF, IBM 000-076, IBM 000-330, IBM 000-331
> [email protected] <javascript:>
>
> 2010/5/21 R.I.Pienaar <[email protected] <javascript:>>
>
>> > The vast majority of our text replacement work we do is for files that
>> > have simple key/value pairs with an assignment operator.
>> >
>> >
>> > foo=bar
>> > foo: bar
>> >
>> >
>> > etc.
>> >
>> >
>> > We occasionally stray outside this with a regexp replacer, but I
>> > totally agree with Daniel here, it's not the most robust thing in the
>> > world.
>> >
>> >
>> > Generally we do this because we want to allow people to customize
>> > extra parts of their config files, and we've switched daemons entirely
>> > for some services, simply based upon their ability to cope with a
>> > parts.d directory or to have "include" directives of some kind.
>> >
>> >
>> > That allows you to ship an absolute config with a default include that
>> > people are free to modify.
>> >
>>
>>
>> fwiw, the newest version of my concat module supports symlinking into a
>> concat file, so if you have a config file that you would like users to drop
>> settings it and you want them to only do so in a very specific place in a
>> file you can now achieve that by building your config file and including a
>> user editable file right where you want it.
>>
>> Very nice feature to give users some rights without loosing control of
>> the file or its structure.
>>
>> It wouldn't be too hard to extend it to make arbitrary user supplied .d
>> directories for daemons that dont support those :)
>>
>> http://github.com/ripienaar/puppet-concat
>>
>>
>> --
>> R.I.Pienaar
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To unsubscribe from this group, send email to [email protected]
>> <javascript:>.
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected]
> <javascript:>.
> To unsubscribe from this group, send email to [email protected]
> <javascript:>.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/efa23924-e6eb-4338-bdb6-648d01923cee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.