Aurelien Degremont
2009-Oct-02 07:40 UTC
[Puppet Users] Puppet way to manage a central file?
Hello I facing I think a typical problem when using Puppet and I''m wondering what is the Puppet way to deal with this. I''m explaining. How do you deal with a file, like /etc/sysconfig/network which have content composed from different aspects (could be network, nfs, nis, ...). So managed by various modules but all of them should add its own stuff to the same file. What is your elegant way to deal with this? Thanks -- Aurelien Degremont CEA --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thomas Bellman
2009-Oct-02 08:48 UTC
[Puppet Users] Re: Puppet way to manage a central file?
Aurelien Degremont wrote:> How do you deal with a file, like /etc/sysconfig/network which have > content composed from different aspects (could be network, nfs, nis, > ...). So managed by various modules but all > of them should add its > own stuff to the same file. > > What is your elegant way to deal with this?Edit the individual settings using e.g. Augeas. Preferably wrap it in a define, so you don''t have to deal with the augeas type directly every time you want to change something in /etc/sysconfig. Shameless plug: I have a define ''rh_sysconfig'' for setting /etc/sysconfig entries in a module I''ve written. You can get it by doing a git clone of http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git. It doesn''t use Augeas for manipulating the file, though, but some custom types for doing even lower level editing of text files. /Bellman --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aurelien Degremont
2009-Oct-02 10:06 UTC
[Puppet Users] Re: Puppet way to manage a central file?
Thomas Bellman a écrit :> Aurelien Degremont wrote: > >> How do you deal with a file, like /etc/sysconfig/network which have >> content composed from different aspects (could be network, nfs, nis, >> ...). So managed by various modules but all > of them should add its >> own stuff to the same file. >> >> What is your elegant way to deal with this? > > Edit the individual settings using e.g. Augeas. Preferably wrap it in > a define, so you don''t have to deal with the augeas type directly every > time you want to change something in /etc/sysconfig.I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas only handles known files (existing lenses). If we trty to handle /etc/our_local_config_file, it is not so easy.> Shameless plug: I have a define ''rh_sysconfig'' for setting /etc/sysconfig > entries in a module I''ve written. You can get it by doing a git clone of > http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git. It doesn''t use Augeas > for manipulating the file, though, but some custom types for doing even > lower level editing of text files.I''m wondering if implementing such low-level define and file edition is the best Puppet approach? Aurelien --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nicolas Szalay
2009-Oct-02 12:08 UTC
[Puppet Users] Re: Puppet way to manage a central file?
Le vendredi 02 octobre 2009 à 12:06 +0200, Aurelien Degremont a écrit :> Thomas Bellman a écrit : > > Aurelien Degremont wrote: > > > >> How do you deal with a file, like /etc/sysconfig/network which have > >> content composed from different aspects (could be network, nfs, nis, > >> ...). So managed by various modules but all > of them should add its > >> own stuff to the same file. > >> > >> What is your elegant way to deal with this? > > > > Edit the individual settings using e.g. Augeas. Preferably wrap it in > > a define, so you don''t have to deal with the augeas type directly every > > time you want to change something in /etc/sysconfig. > > I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas only handles > known files (existing lenses). If we trty to handle /etc/our_local_config_file, it is not > so easy.A bunch of templates + concatened_file would do the trick I suppose. Nico.
Aurelien Degremont
2009-Oct-02 12:21 UTC
[Puppet Users] Re: Puppet way to manage a central file?
Nicolas Szalay a écrit :> Le vendredi 02 octobre 2009 à 12:06 +0200, Aurelien Degremont a écrit : >> Thomas Bellman a écrit : >>> Aurelien Degremont wrote: >>> >>>> How do you deal with a file, like /etc/sysconfig/network which have >>>> content composed from different aspects (could be network, nfs, nis, >>>> ...). So managed by various modules but all > of them should add its >>>> own stuff to the same file. >>>> >>>> What is your elegant way to deal with this? >>> Edit the individual settings using e.g. Augeas. Preferably wrap it in >>> a define, so you don''t have to deal with the augeas type directly every >>> time you want to change something in /etc/sysconfig. >> I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas only handles >> known files (existing lenses). If we trty to handle /etc/our_local_config_file, it is not >> so easy. > > A bunch of templates + concatened_file would do the trick I suppose.Indeed, but I was seeking if there was something else than a "trick"? -- Aurelien Degremont CEA --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aurelien Degremont wrote:> I put /etc/sysconfig/network as an example. AFAIK, unfortunately, > Augeas only handles known files (existing lenses). If we trty to > handle /etc/our_local_config_file, it is not so easy.Indeed. Really silly design. There was a reason that I wrote "e.g." in my suggestion for Augeas; I often use my own textfile editing types instead.>> Shameless plug: I have a define ''rh_sysconfig'' for setting /etc/sysconfig >> entries in a module I''ve written. You can get it by doing a git clone of >> http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git. It doesn''t use Augeas >> for manipulating the file, though, but some custom types for doing even >> lower level editing of text files.> I''m wondering if implementing such low-level define and file edition is > the best Puppet approach?The Puppet:y approach would, imho, be to have resource types on the same level as the builtin resource types ''host'', ''mount'', ''sshkey'', and so on. My ''rh_sysconfig'' definition is actually a bit too low-level; better would be a ''sysconfig'' definition/type that knows to edit files in /etc/conf.d on Gentoo, /etc/sysconfig on RedHat, and so on, but I haven''t gotten around to do that yet. (One problem for these kinds of settings, though, is that they have different names and values on different platforms, so the sysadmins needs to handle that in their manifests anyway.) And of course you would want a ''firewall'' or ''iptables'' type, types for adding /etc/sudoers entries, types for manipulating Apache configs, and so on, and so on. Whether those types are implemented as builtin types in Puppet, as custom types, or defines built on top of lower-level file editing tools like Augeas and/or my textfile editing types, doesn''t matter much. But you very likely want something working on that level of abstraction. Then you can create definitions on top of those for even higher levels of abstraction. However, since the number of config file formats is nearly infinite, we also need to have the tools for sysadmins to write such types or definitions themselves. So we have Augeas, we have my textfile editing types, and we have exec to call out to sed/perl/whatever. And we have the ability to write our own custom types for full power. That''s *my* take on it, at least. /Bellman --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Gliwinski
2009-Oct-02 13:44 UTC
[Puppet Users] Re: Puppet way to manage a central file?
On Friday 02 October 2009 11:06:39 Aurelien Degremont wrote:> Thomas Bellman a écrit : > > Aurelien Degremont wrote: > >> How do you deal with a file, like /etc/sysconfig/network which have > >> content composed from different aspects (could be network, nfs, nis, > >> ...). So managed by various modules but all > of them should add its > >> own stuff to the same file. > >> > >> What is your elegant way to deal with this? > > > > Edit the individual settings using e.g. Augeas. Preferably wrap it in > > a define, so you don''t have to deal with the augeas type directly every > > time you want to change something in /etc/sysconfig. > > I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas > only handles known files (existing lenses). If we trty to handle > /etc/our_local_config_file, it is not so easy.I usually handle that by distributing custom augeas lenses with puppet and putting them in /usr/share/augeas/lenses/. This isn''t actually very hard as most of those lenses are slightly customized versions of lenses bundled with augeas (very often only with adjusted filter to include the file I need to change). That is unless you have a not-yet-supported config file type or a really hard to handle one. Suppose augeas could be a bit more flexible with regards to the file filters, or at least allowing to modify it on runtime :) -- Michael Gliwinski Henderson Group Information Services 9-11 Hightown Avenue, Newtownabby, BT36 4RT Phone: 028 9034 3319 ********************************************************************************************** The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to the email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing client engagement leter or contract. If you have received this email in error please notify support@henderson-group.com John Henderson (Holdings) Ltd Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT. Registered in Northern Ireland Registration Number NI010588 Vat No.: 814 6399 12 ********************************************************************************* --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hello, ----- "Aurelien Degremont" <aurelien.degremont@cea.fr> wrote:> How do you deal with a file, like /etc/sysconfig/network which have > content composed from > different aspects (could be network, nfs, nis, ...). So managed by > various modules but all > of them should add its own stuff to the same file.In the case of sysconfig files you''d need something clever, what if say 2 modules tried to set HOSTNAME= or any of the other variables, which one would win? it would not be predictable. A lens or custom type would be best. However, in many cases a simple snippet based system will do what you want, for example my MOTD files advertise which modules are on the machine and I do this using my concat snippets defined type [1] define motd::register($content = "", $order = 10) { concat_snippet{"motd_${name}": owner => root, group => root, directory => "/etc/motd.d", content => "\t\t- ${msg}\n", order => $order, } } class named::master { motd::register{"bind master server": } } and the end result is something like: Puppet Modules: - apache - bind master server - iptables 1 - http://nephilim.ml.org/~rip/puppet/concatfile/ -- R.I.Pienaar --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Oct-04 03:48 UTC
[Puppet Users] Re: Puppet way to manage a central file?
On Fri, 2009-10-02 at 12:06 +0200, Aurelien Degremont wrote:> I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas only handles > known files (existing lenses). If we trty to handle /etc/our_local_config_file, it is not > so easy.If there is a lens already, but the lens doesn''t look for the file in your custom place, I am working on a patch for the augeas type that lets you set which file to read and what lens to use with additional parameters. (That was one issue that came up in the Augeas session at puppetcamp yesterday) If there isn''t a lens yet, I''ll be more than happy to help - but it''s probably best if we discuss that on the Augeas mailing list. David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
John Warburton
2009-Oct-06 05:40 UTC
[Puppet Users] Re: Puppet way to manage a central file?
I''d love a "+3 lens of anything", where I know how the line should be constructed, just use Augeas as the method to deliver the change. At the moment, I still use http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText in an number of cases which seems hacky to me John 2009/10/4 David Lutterkort <lutter@redhat.com>> > On Fri, 2009-10-02 at 12:06 +0200, Aurelien Degremont wrote: > > I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas > only handles > > known files (existing lenses). If we trty to handle > /etc/our_local_config_file, it is not > > so easy. > > If there is a lens already, but the lens doesn''t look for the file in > your custom place, I am working on a patch for the augeas type that lets > you set which file to read and what lens to use with additional > parameters. (That was one issue that came up in the Augeas session at > puppetcamp yesterday) > > If there isn''t a lens yet, I''ll be more than happy to help - but it''s > probably best if we discuss that on the Augeas mailing list. > > David > > > > > >-- John Warburton Ph: 0417 299 600 Email: jwarburton@gmail.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aurelien Degremont
2009-Oct-06 15:48 UTC
[Puppet Users] Re: Puppet way to manage a central file?
Thanks you all for you answers. It seems there is no ''common'' way to handle this. I think I will look more closely to Augeas and it seems having some main-purpose lenses (as most of config files use often the same kind of syntax) is a really good idea (spacevars, shellvars, ...). But being stuck with the hardcoded paths is really blocking. A patch is welcome :) Aurelien David Lutterkort a écrit :> On Fri, 2009-10-02 at 12:06 +0200, Aurelien Degremont wrote: >> I put /etc/sysconfig/network as an example. AFAIK, unfortunately, Augeas only handles >> known files (existing lenses). If we trty to handle /etc/our_local_config_file, it is not >> so easy. > > If there is a lens already, but the lens doesn''t look for the file in > your custom place, I am working on a patch for the augeas type that lets > you set which file to read and what lens to use with additional > parameters. (That was one issue that came up in the Augeas session at > puppetcamp yesterday) > > If there isn''t a lens yet, I''ll be more than happy to help - but it''s > probably best if we discuss that on the Augeas mailing list. > > David > > > > > >-- Aurelien Degremont CEA --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Shafer
2009-Oct-06 18:04 UTC
[Puppet Users] Re: Puppet way to manage a central file?
On Mon, Oct 5, 2009 at 11:40 PM, John Warburton <jwarburton@gmail.com>wrote:> I''d love a "+3 lens of anything", where I know how the line should be > constructed, just use Augeas as the method to deliver the change. > >Your ''+3 lens of anything'' is no match for my ''unstructured file of exceptional sprawl''. Have at you! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---