The deb-oriented package providers (and others perhaps, it''s only debian I''m looking at right now) allow one to set a seedfile with the appropriate debconf responses when installing a package. However, there doesn''t seem to be a tidy way inherent to puppet to handle reconfiguring the package if the seedfile changes. It can be done quite easily with something like the following: exec{ "/usr/bin/debconf-set-selections $seedfile": subscribe => File[$seedfile], refreshonly => true, } exec{ "/usr/sbin/dpkg-reconfigure $package": subscribe => File[$seedfile], refreshonly => true, } What would be involved in adding a reconfigure parameter to the package provider to streamline this? It''s trivial to wrap the above code in a defined type, but it seems like it should be part of the package provider to me. I''ve had a quick look already, and most of it seems straightforward except I''m not sure how to arrange for the package provider to be notified of a change in the seedfile.
> What would be involved in adding a reconfigure parameter to the package > provider to streamline this? It''s trivial to wrap the above code in a > defined type, but it seems like it should be part of the package > provider to me. I''ve had a quick look already, and most of it seems > straightforward except I''m not sure how to arrange for the package > provider to be notified of a change in the seedfile. >To answer my own question: remotefile { "/var/lib/puppet/localeconf.seed": mode => 660, source => ''/apps/debconf/localeconf.seed'', } package { [localeconf]: ensure => installed, require => File[''/var/lib/puppet/localeconf.seed''], responsefile => ''/var/lib/puppet/localeconf.seed'', subscribe => File[''/var/lib/puppet/localeconf.seed''], } Will arrange for the package provider to be sent an event on change. Adding a refresh method to type/package.rb will arrange for the provider to handle getting a refresh: # type/package/rb def refresh self.info "Refreshing package" provider.reconfigure end And adding a ''reconfigure'' method to the specific provider will handle that: #provider/package/apt.rb dpkgreconfigure => "/usr/sbin/dpkgreconfigure ... def reconfigure self.run_preseed self.run_reconfigure end def run_reconfigure self.info ("Reconfigure %s " % @model[:name]) dpkgreconfigure "-pcritical", @model[:name] end I haven''t submitted this as a diff because it obviously needs a lot of error checking put in place on it. Having gone down this path, I''ve discovered that one of the packages I wanted this functionality for doesn''t need it. (Perhaps offtopic ? Relevant to any debian/ubuntu admins who might want to use this sort of functionality.) When debconf manages a config file (such as /etc/default/mdadm), there are big warnings around to not edit the file, but to use dpkg-reconfigure instead. That''s fine, you''d think - you should be able to reseed debconf via debconf-set-selections, and run dpkg-reconfigure, and it will pick up the new selections. However, it appears that many debian and ubuntu packagers acknowledge that people don''t listen to the debconf warnings, and during the debconf stage will overwrite any debconf answers with data stored in the config file they manage. The upshot is if I try to use debconf-set-selections to reseed say, mdadm, when I run dpkg-reconfigure on mdadm it will reread /etc/default/mdadm and then use those values as the defaults, trumping my reseed. I can get around this by using puppet to manage /etc/default/mdadm of course, but I was trying to avoid using puppet to manage debconf-managed files. I suspect all files in /etc/default are all managed like this within debconf, as I''ve seen the behaviour elsewhere as well. Why should we care about it? I''m mostly interested in this for future proofing myself against the eventuality puppet is removed from service. Any step that I would have done via dpkg-reconfigure, I would like to be able to do via puppet. The good news is that the reconfigure methods I outlined above will work on other packages. EG, if you want to change your locale settings on all your boxes, you can just change the preseed file and it will trigger an update. You can manage locales manually, but they''re nowhere as easy to manage as say, timezones. Daniel
On Jun 9, 2007, at 3:44 PM, Daniel Lawson wrote:> To answer my own question: > > remotefile { "/var/lib/puppet/localeconf.seed": > mode => 660, > source => ''/apps/debconf/localeconf.seed'', > } > > package { [localeconf]: > ensure => installed, > require => File[''/var/lib/puppet/localeconf.seed''], > responsefile => ''/var/lib/puppet/localeconf.seed'', > subscribe => File[''/var/lib/puppet/localeconf.seed''], > } > > > Will arrange for the package provider to be sent an event on change. > Adding a refresh method to type/package.rb will arrange for the > provider > to handle getting a refresh: > # type/package/rb > def refresh > self.info "Refreshing package" > provider.reconfigure > end > > And adding a ''reconfigure'' method to the specific provider will > handle that: > > #provider/package/apt.rb > dpkgreconfigure => "/usr/sbin/dpkgreconfigureThis would be very easy to add generically -- I''d set it up so that all resource types would look for a ''refresh'' method on their providers, and if present, it would be called. So, you''d define a ''refresh'' method on the apt provider (or, more likely, the dpkg provider), and everything else would happen automatically when the package received events from the file. Note that Puppet automatically sets up a ''require'' relationship between a package and its response file, but not a ''subscribe'' relationship (note also that having both is redundant -- the ''require'' is ignored).> ... > > def reconfigure > self.run_preseed > self.run_reconfigure > end > > def run_reconfigure > self.info ("Reconfigure %s " % @model[:name]) > dpkgreconfigure "-pcritical", @model[:name] > end > > > I haven''t submitted this as a diff because it obviously needs a lot of > error checking put in place on it. Having gone down this path, I''ve > discovered that one of the packages I wanted this functionality for > doesn''t need it.Go ahead and submit it as an enhancement request. -- Don''t throw away the old bucket until you know whether the new one holds water. -- Swedish Proverb --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
David Schmitt
2007-Jun-18 22:08 UTC
Debconf Behavious (was: Re: ''reconfigurable'' option for package providers)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday 09 June 2007, Daniel Lawson wrote:> When debconf manages a config file (such as /etc/default/mdadm), there > are big warnings around to not edit the file, but to use > dpkg-reconfigure instead. That''s fine, you''d think - you should be able > to reseed debconf via debconf-set-selections, and run dpkg-reconfigure, > and it will pick up the new selections. However, it appears that many > debian and ubuntu packagers acknowledge that people don''t listen to the > debconf warnings, and during the debconf stage will overwrite any > debconf answers with data stored in the config file they manage. > > The upshot is if I try to use debconf-set-selections to reseed say, > mdadm, when I run dpkg-reconfigure on mdadm it will reread > /etc/default/mdadm and then use those values as the defaults, trumping > my reseed. I can get around this by using puppet to manage > /etc/default/mdadm of course, but I was trying to avoid using puppet to > manage debconf-managed files. > I suspect all files in /etc/default are all managed like this within > debconf, as I''ve seen the behaviour elsewhere as well. > > Why should we care about it? I''m mostly interested in this for future > proofing myself against the eventuality puppet is removed from service. > Any step that I would have done via dpkg-reconfigure, I would like to be > able to do via puppet.Reading values from configuration files as default values into debconf prior to reconfiguring is the proscribed Debian Default Behaviour. Every package should work like this, since as it is often repeated: "debconf is no registry". The Right Way therefore is to handle only the most pressing (i.e. priority critical) questions via preseeding and then configure anything else "manually", since you always will need stuff like the configfile->servicerestart derpendency information in puppet _anyways_.> The good news is that the reconfigure methods I outlined above will work > on other packages. EG, if you want to change your locale settings on > all your boxes, you can just change the preseed file and it will trigger > an update. You can manage locales manually, but they''re nowhere as easy > to manage as say, timezones.Regards, David - -- - - hallo... wie gehts heute? - - *hust* gut *rotz* *keuch* - - gott sei dank kommunizieren wir über ein septisches medium ;) -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGdwJQ/Pp1N6Uzh0URAv7wAJsHGAW06mhkQWD4LrbesjV7dqh8cgCdGUuu 1N9N7Q5qhXInEBmDGmZ0qho=F/OX -----END PGP SIGNATURE-----
Maybe Matching Threads
- ssh drops privs when it can't find ~/.ssh/prng_seed
- ssh-rand-helper
- vhost && kernel BUG at /build/linux/mm/slub.c:3352!
- vhost && kernel BUG at /build/linux/mm/slub.c:3352!
- Fwd: Dynamic DNS Updates not working. samba_dnsupdate : (sambalist: message 3 of 20) RuntimeError: (sambalist: to exclusive) kinit for [DC@Realm] failed (Cannot contact any KDC for requested realm)