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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.