Ross W
2011-Feb-07 17:30 UTC
[Puppet Users] freebsd rc.conf type - looking for beta testers
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. -- 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.
Stefan Schulte
2011-Feb-08 05:44 UTC
Re: [Puppet Users] freebsd rc.conf type - looking for beta testers
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
Ross W
2011-Feb-08 19:13 UTC
Re: [Puppet Users] freebsd rc.conf type - looking for beta testers
First off, I apologize for the bad coding - I''m not really familiar with ruby at all, so a lot of stuff/logic was cobbled together from other puppet providers/etc, and sometimes there wasn''t much documentation. I can tell Puppet has evolved very quickly. :-) 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. >Yes - I realized the true functionality of instances/prefetch afterwards while working out a different issue. I was originally under the impression that instances was to actually preload the current state data en mass if possible at the beginning so that each resource doesn''t need to be queried in turn on startup. This way, purging your resource with the resource type should work> and I guess even »puppet resource rcconf« should work. >Whooops, I pushed old code up to that repo. Fixed that bug along with a few others a while ago. It''s a fully working type/provider at the current time. I just threw it all into a branch off my main puppet repo since it''s a more logical spot for it to be: https://github.com/westr/puppet/tree/feature%2Fmaster%2Fsvc-sysrc Thanks, Ross. -- 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.
Russell Jackson
2011-Feb-08 20:10 UTC
Re: [Puppet Users] freebsd rc.conf type - looking for beta testers
On 02/07/2011 09:30 AM, 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. >You can already use augeas to do this. augeas { "item_flags": context => "/files/etc/rc.conf", changes => "set item_flags ''--something''" } The textproc/augeas port has lens for both /etc/rc.conf and /boot/loader.conf -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield -- 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.