Hi .*, I''m looking for a more or less thorough documentation of the usage of the parsedfile provider. I''m already scanning through all the existing providers but some open questions remain. In particular I want to write a provider editing the /etc/sysconf/ files, in particular I need to alter the MODULES_LOADED_ON_BOOT in the /etc/sysconfig/kernel (on SLES). The entry looks like: MODULES_LOADED_ON_BOOT="module1 module2" My goal ist to have a type, which can append a "module3" to this entry, or replace the whole list, etc. (to stay generic for different files in /etc/sysconfig). I already manage to get the file scanned etc. (using also post_parse, process, to_line) and have the entry manipulated. But for appending I would need to have the resource checked in a custom way (like the ''retrive'' method to scan if the module already exists is already in the list). Furthermore I don''t understand how to access the parameters in the provider, which are given in the resource definition. This kind of question arise more and more while working on the provider. Therefore a ''complete'' documentation would be nice, or a ''complete'' example using all the possible hooks. Thanks a lot for some more hints, Frederik -- 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
2010-Feb-23 00:09 UTC
Re: [Puppet Users] parsedfile provider documentation?
On Mon, 2010-02-22 at 10:45 +0100, Frederik Wagner wrote:> MODULES_LOADED_ON_BOOT="module1 module2" > > My goal ist to have a type, which can append a "module3" to this > entry, or replace the whole list, etc. (to stay generic for different > files in /etc/sysconfig).If you can live with replacing the entire list, you can just use augeas: augeas { "my_boot_modules": changes => "set /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT ''$mymodules''" } If you need to build the list up from something else, you might want to wrap the above into a define that computes $mymodules from that something. There''s also ways to make this just append a specific module, but that would require some work on the Augeas side. 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.
Frederik Wagner
2010-Feb-23 12:42 UTC
Re: [Puppet Users] parsedfile provider documentation?
Hi David, On Tue, Feb 23, 2010 at 1:09 AM, David Lutterkort <lutter@redhat.com> wrote:> On Mon, 2010-02-22 at 10:45 +0100, Frederik Wagner wrote: >> MODULES_LOADED_ON_BOOT="module1 module2" >> >> My goal ist to have a type, which can append a "module3" to this >> entry, or replace the whole list, etc. (to stay generic for different >> files in /etc/sysconfig). > > If you can live with replacing the entire list, you can just use augeas: > > augeas { "my_boot_modules": > changes => "set /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT ''$mymodules''" > } > > If you need to build the list up from something else, you might want to > wrap the above into a define that computes $mymodules from that > something.I would need to append single modules to the list, therefore I was thinking to write the provider.> > There''s also ways to make this just append a specific module, but that > would require some work on the Augeas side.does this need new features on the augeas side? Or is it already doable with the current augeas? Anyway a bit more documentation on the ParseFile provider would be nice. Thanks a lot, Fredeirk> 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. > >-- 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.
Frederik Wagner
2010-Feb-24 10:28 UTC
Re: [Puppet Users] parsedfile provider documentation?
Hi David, I was just looking a bit more into augeas: Is there a way to set variables in augeas wit values obtained by a ''get'' statement? Like: ... augtool> get /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT = "ipv6" ... Thus having a variable $oldval with values ''ipv6'' which I could reuse to set the value again. In this way an appending of values would be easy, e.g.: ... augtool> set /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT "$oldval sunrpc" Thanks and bye, Frederik On Tue, Feb 23, 2010 at 1:42 PM, Frederik Wagner <fnerdwq@googlemail.com> wrote:> Hi David, > > On Tue, Feb 23, 2010 at 1:09 AM, David Lutterkort <lutter@redhat.com> wrote: >> On Mon, 2010-02-22 at 10:45 +0100, Frederik Wagner wrote: >>> MODULES_LOADED_ON_BOOT="module1 module2" >>> >>> My goal ist to have a type, which can append a "module3" to this >>> entry, or replace the whole list, etc. (to stay generic for different >>> files in /etc/sysconfig). >> >> If you can live with replacing the entire list, you can just use augeas: >> >> augeas { "my_boot_modules": >> changes => "set /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT ''$mymodules''" >> } >> >> If you need to build the list up from something else, you might want to >> wrap the above into a define that computes $mymodules from that >> something. > > I would need to append single modules to the list, therefore I was > thinking to write the provider. > >> >> There''s also ways to make this just append a specific module, but that >> would require some work on the Augeas side. > > does this need new features on the augeas side? Or is it already > doable with the current augeas? > > Anyway a bit more documentation on the ParseFile provider would be nice. > > Thanks a lot, > Fredeirk > >> 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. >> >> >-- 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
2010-Feb-24 23:28 UTC
Re: [Puppet Users] parsedfile provider documentation?
On Tue, 2010-02-23 at 13:42 +0100, Frederik Wagner wrote:> > If you can live with replacing the entire list, you can just use augeas: > > > > augeas { "my_boot_modules": > > changes => "set /files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT ''$mymodules''" > > } > > > > If you need to build the list up from something else, you might want to > > wrap the above into a define that computes $mymodules from that > > something. > > I would need to append single modules to the list, therefore I was > thinking to write the provider.Yes, that''s one way to do it - you could base that provider off Augeas; the heart of it would be a method like (needs to be split up a bit to mesh with Puppet''s notion of checking if a change is needed, reporting what has changed, and noop mode) def append_module(module) aug = Augeas::open("/", Augeas::NO_MODL_AUTOLOAD) begin aug.set("/augeas/load/Xfm/lens", "Shellvars.lns") aug.set("/augeas/load/Xfm/incl", "/etc/sysconfig/kernel") aug.load mod_path = "/files/etc/sysconfig/kernel/MODULES_LOADED_ON_BOOT" mods = aug.get(mod_path) || "" unless mods.split().include?(module) mods = mods.split().push("x").join(" ") aug.set(mod_path, mods) aug.save end ensure aug.close if aug end end> > There''s also ways to make this just append a specific module, but that > > would require some work on the Augeas side. > > does this need new features on the augeas side? Or is it already > doable with the current augeas?It doesn''t need new features, but it would require that you change the stock shellvars lens so that it treats the MODULES_LOADED_ON_BOOT special, and splits it into several tree nodes. 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.
David Lutterkort
2010-Feb-24 23:30 UTC
Re: [Puppet Users] parsedfile provider documentation?
On Wed, 2010-02-24 at 11:28 +0100, Frederik Wagner wrote:> I was just looking a bit more into augeas: > Is there a way to set variables in augeas wit values obtained by a > ''get'' statement?It''s possible if you use Augeas from Ruby by doing something like aug = Augeas::open(...) value = aug.get(path) new_value = modify(value) aug.set(path, new_value) aug.save It is not possible from the augeas type in Puppet. 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.