On 05-09-10 12:02, Marcin Owsiany wrote: > On Tue, Aug 31, 2010 at 04:03:35PM +0200, Martijn Grendelman wrote: >> What I would like, is for Puppet to run `aptitude update` before it >> installs or upgrades packages. > > FYI you're likely to encounter problems when using aptitude provider for > package management. See Debian bugs #445034 #445035
Thanks. The former is not really important to me, since I never use
aptitude that way. The latter is probably a little more tricky, but at
least the 'unknown package' case is handled by Puppet itself:
# Yay, stupid aptitude doesn't throw an error when the package is missing.
if args.include?(:install) and output =~ /Couldn't find any package/
raise Puppet::Error.new(
"Could not find package #{self.name}"
)
end
I have now solved my problem by using a custom provider for packages, that
is based on the aptitude provider, but simply adds this:
# See if we need to run aptitude update before installing this package
if not File.exists?("/tmp/puppet-iphionapt")
FileUtils.touch("/tmp/puppet-iphionapt")
aptitude("update")
end
I just haven't found a suitable way to clean up the tempfile from within
Puppet without touching any of Puppet's own files, so I use a cronjob for
that now. Maybe I'll switch to a 'postrun_command', or does anyone have a
better idea?
Best regards,
Martijn.
smime.p7s
Description: S/MIME Cryptographic Signature
