On Mon, Feb 07, 2011 at 12:30:29PM -0500, Ross W wrote: > While working on a bunch of freebsd servers, one feature that I found > lacking was the ability to nicely modify rc.conf variables (eg: > item_flags="--something") for installed ports/applications and have a > service do dependency checking so it restarts if it changes. > > So a wrote a new puppet type (rcconf) to specifically handle this. It's got > a single provider at the moment, which uses the sysrc script (available at > http://druidbsd.sourceforge.net/) to do key/value modifications. BTW: it's > a nice script I'd recommend freebsd admins get anyways. > > I've placed the code for the new type at: > https://github.com/westr/westr-puppet-extras/tree/master/freebsd/rcconf > > If anyone wants to download and test, that would be appreciated. Please > note this is definitely what I'd call beta software that's only been tested > with Puppet v2.6.x > > Simple documentation is in the README file in the directory. > > R. >
Hi Ross,
I had a short look at you code and I dont know if this is intentional
but I think you dont use "instances" in the way it was meant to be. It
shouldn't return an array of hashes but an array of providers.
So instead of
keysall << keyin.dup
you'll do
instances << new(keyin)
If you call providerclass.new(a_hash) all items in a_hash will be put in
the property_hash of the provider instance.
Prefetch will become
def self.prefetch(userkeys)
instances.each do |provider|
if matchresource = userkeys[provider.name]
# resource object to be configured.
matchresource.provider = provider
end # if
end # eachloop
end
This way, purging your resource with the resource type should work
and I guess even »puppet resource rcconf« should work.
If you think you can trust your prefetched values during a puppetrun
(e.g. no installed package will change the prefetched value) you can
even reduce a few methods.
def exists?
get(:ensure) != :absent
end
def value
get(:value)
end
get will return the value in the property_hash. If it is not stored in
the property_hash it will return :absent.
-Stefan
pgpVsS5DmIAOl.pgp
Description: PGP signature
