On 2019-04-07 14:47, KRouth Clinipace wrote:
> 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
>
Well, functions are ordinary on the compiling side. If you can figure
out what to do when compiling that is preferable.
Alternatively, you can call functions on the agent side by using a
Deferred value that delays the call and makes it on the agent side.
You need Puppet 6 to be able to do that. (And if you need custom logic
you can write your own function in Ruby using the function API).
To answer if there is a better way we need to understand what you are
actually doing (I did not try to make sense of what your exec and the
perl logic actually does...
Best
- henrik
> 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 <
http://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
>
marley...@gmail.com <javascript:>
>
> 2010/5/21 R.I.Pienaar <
r...@devco.net <javascript:>>
> <javascript:>.
> To unsubscribe from this group, send email to
>
puppet...@googlegroups.com <javascript:>.
> <
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
puppet...@googlegroups.com
> <javascript:>.
> To unsubscribe from this group, send email to
>
puppet...@googlegroups.com <javascript:>.
> <
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
puppet-users...@googlegroups.com
> <mailto:
puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/puppet-users/efa23924-e6eb-4338-bdb6-648d01923cee%40googlegroups.com
> <
https://groups.google.com/d/msgid/puppet-users/efa23924-e6eb-4338-bdb6-648d01923cee%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/