On 14/04/11 06:26, Giovanni Bordello wrote: > I wonder if there is an easy way to change variables in the standard > linux config files in /etc/sysconfig/* on RHEL or /etc/defaults/* on > Debian. > > For instance I would like to set the host name in /etc/sysconfig/network > with something like: > > configoption { "/etc/sysconfig/network": > option => "HOSTNAME", > value => "host.example.com", > ensure => exact, # or "includes" or "remove" or "commentout" > } > > Is there an easy way to do that? Or should I invent the wheel?
Check out the Augeas project and associated Puppet type. Here's a RHEL example, though similar things should work with /etc/default/ on Debian: augeas { "nisdomain": context => "/files/etc/sysconfig/network", changes => "set NISDOMAIN example.net", } To remove it: changes => "rm NISDOMAIN", Commenting out is tricky though.. perhaps you could use 'mv' when it arrives, but that doesn't completely solve the problem. Here are a few resources: http://projects.puppetlabs.com/projects/1/wiki/Puppet_Augeas http://docs.puppetlabs.com/references/latest/type.html#augeas http://augeas.net/tour.html http://r.pinson.free.fr/augeas/augeas-book.pdf The best way to learn Augeas and how to modify the tree is to explore using the augtool command. There are also a few recipes for changing individual lines in files on the Puppet wiki: http://projects.puppetlabs.com/projects/1/wiki/Simple_Text_Patterns Both solutions could be wrapped up in a define() to give you an interface similar to the one you want. -- Dominic Cleal Red Hat Consulting m: +44 (0)7818 512168 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.