Ask Your Question
0

search and replace

asked 2015-10-08 06:47:18 -0500

sujay gravatar image

Hi, need some help in search and replace content

1.txt file has 10.10.10.10 IP. + some text content 2.txt file has 20.20.20.20 IP. + some text content

and i want to replace the IP address in 2.txt with IP address in 1.txt with out disturbing any other information in 2.txt.

How is it possible to do this with PUPPET??

Thanks & Regards, sujaykumar

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-10-08 13:11:56 -0500

lupin gravatar image

Hi,

How do you intend to do it? You have options of using template,gsub(function), augeas or plain sed/perl string replacement via exec resource.

Puppet could not be the right tool for this job but without background info it's difficult to judge.

edit flag offensive delete link more
0

answered 2015-10-08 23:36:54 -0500

sujay gravatar image

Hi Lupin,

I am interested in "plain sed/perl string replacement". Can you help me in this regard. Actually i am working in FUEL-Openstack and at one point i want to replace all the string contents in one file with the IP address of the controller available in another file.

Thanks, sujay

edit flag offensive delete link more

Comments

What have you tried? Did you check the exec resource? e.g. exec { 'search_replace': command => "perl -pi -e s#replacement#target#g file_name", unless => 'grep -q target file_name', }

lupin gravatar imagelupin ( 2015-10-10 04:00:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-10-08 06:47:18 -0500

Seen: 183 times

Last updated: Oct 08 '15