Help with puppet

23 views
Skip to first unread message

Gayatri Swaminathan

unread,
Mar 30, 2014, 7:44:14 PM3/30/14
to puppet...@googlegroups.com
Hi All,

I am trying to learn puppet.

I want to writte a script to determine the machine’s local IPV4 address,
locate all files with the extension “cfg” in /home/mnt/, and replace all occurrences of “example.com” with that IP, and change the extension of each file to .conf.

Is it do-able? Can any of you guide me?

Ashish

unread,
Mar 31, 2014, 3:03:29 AM3/31/14
to puppet...@googlegroups.com
Hello,

I have tried and it was working, extend the pp as per your requirements.
I haven't set any metaparameter. please add as per your requirements.

Let me know if you find any difficulty.

# Testing

class locate {

Exec { path => "/usr/bin:/usr/sbin:/bin:/sbin" }

        exec { "replace" : command => "sed -i 's/example.com/$ipaddress/' `find /root/scripts/ -type f -iname '*.cfg'`" }

        exec { "extension" : command => "rename .cfg .conf `find /root/scripts/ -type f -iname '*.cfg'`" }

        Exec['replace']->Exec['extension']
} # End of locate

Output :
-------------
opensuse01:~/scripts # ll
total 12
-rw-r--r-- 1 root root 12 Mar 31 12:30 1.conf
-rw-r--r-- 1 root root 12 Mar 31 12:30 2.conf
-rw-r--r-- 1 root root 12 Mar 31 12:30 3.conf
opensuse01:~/scripts # cat *
196.1.1.136
196.1.1.136
196.1.1.136
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c33b2bc1-e88d-4924-a3a5-cf59d3c3ce2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages