Giovanni Bordello
2011-Apr-14 05:26 UTC
[Puppet Users] Easy setting vars in /etc/sysconfig
Hi there, 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? Thanks GiBo -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dominic Cleal
2011-Apr-14 08:04 UTC
Re: [Puppet Users] Easy setting vars in /etc/sysconfig
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 14/04/11 20:04, Dominic Cleal wrote:> 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: > Check out the Augeas project and associated Puppet type.Thanks! There''s so many things to learn about Puppet & Co, hopefully in the end all the hard work will bring some juicy fruits :) GiBo -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.