Re: [Puppet Users] Replace some text

2019-04-09 Thread KRouth Clinipace
My experience with using file_line (i use it elsewhere) is that it replaces the entire line. (maybe this behavior has been changed, we are running Puppet 3.8). I am looking for a way to substitute a part of the line, leaving the rest intact. thanks :) kevin On Tue, Apr 9, 2019 at 1:28 AM Dirk Hei

Re: [Puppet Users] Replace some text

2019-04-08 Thread Dirk Heinrichs
Am Sonntag, den 07.04.2019, 05:47 -0700 schrieb KRouth Clinipace: Know i will see the other options proposed here puppetlabs::stdlib -> file_line Why reinvent the wheel? Bye... Dirk -- Dirk Heinrichs Senior Systems Engineer, Delivery Pipeline OpenText ™ Discovery | Recommind Phone: +49 2226

Re: [Puppet Users] Replace some text

2019-04-08 Thread Ben Ford
It looks like what you're trying to do is inline editing of /etc/bashrc, but still let people poke at it themselves. That's a fragile position to be in. For example, given your regex solution, what's to stop someone from doing something like innocently defining their $PS1 iteratively? Something lik

Re: [Puppet Users] Replace some text

2019-04-08 Thread Henrik Lindberg
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

Re: [Puppet Users] Replace some text

2019-04-08 Thread KRouth Clinipace
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, $repla

Re: [Puppet Users] Replace some text

2010-05-21 Thread Marley Bacelar
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'", } }

Re: [Puppet Users] Replace some text

2010-05-21 Thread R.I.Pienaar
> 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 ro

Re: [Puppet Users] Replace some text

2010-05-21 Thread Nigel Kersten
On Fri, May 21, 2010 at 6:08 PM, Daniel Pittman wrote: > Marley Bacelar writes: > > > I need to replace some text in a file... there is some type, that i can > pass > > a value and to be replace and the destination file? > > I know this sounds like a great idea, but decades of experience with pu

Re: [Puppet Users] Replace some text

2010-05-21 Thread Daniel Pittman
Marley Bacelar writes: > I need to replace some text in a file... there is some type, that i can pass > a value and to be replace and the destination file? I know this sounds like a great idea, but decades of experience with puppet and proceeding tools tell us that editing the content of files i

Re: [Puppet Users] Replace some text

2010-05-21 Thread Patrick
You might want to check out Augeas. It might be easier to use. I've seen a simple define that does that, but I can't find it. It had a grep statement in unless, and used sed to make the change. A much more complicated example can be found at http://projects.puppetlabs.com/projects/puppet/wik

[Puppet Users] Replace some text

2010-05-21 Thread Marley Bacelar
I need to replace some text in a file... there is some type, that i can pass a value and to be replace and the destination file? or anyone here have some class who does that? -- Marley Bacelar Project Fedora Ambassador VCP, VSP. VTSP., ITILF, IBM 000-076, IBM 000-330, IBM 000-331 marleybace...@gm