Re: [Puppet Users] Puppet + APT, I am lost...

Silviu Paragina
Mon, 06 Sep 2010 17:56:30 -0000

On 01.09.2010 01:35, Martijn Grendelman wrote:
> Mathias Gug schreef:
>>> I am not sure how I said I want to do an update before /every/
package
>>> install. Once at the start of a Puppet-run, /IF/ one or more
packages
>>> need to be installed, would suffice.
>> You may run into a chicken-egg problem. Packages that are configured as
>> "ensure =>  latest" can only be upgraded by puppet if the
local apt cache
>> files are up-to-date.
>>
>> IOW puppet relies on the local apt files to figure out if packages need
>> to be updated. And to get new local apt files apt-get update needs to
be
>> run.
>>
> I am aware of that, but that''s not a problem. I could easily run
an
> update every day outside of Puppet (on Debian, APT installs a cronjob
> that can take care of this by default, it just needs to be configured).
>
> That way, Puppet would pick up the new versions sooner or later. But
> what I am trying to achieve, has a different background.
>
> Our development team regularly releases new software, packaged in a
> Debian package with a unique name. The idea is that we just give Puppet
> a new package {foo: } and have these new packages be installed ASAP. We
> even use triggered runs to speed things up and to make sure that several
> servers remain identical.
>
> But for this to work, the Puppet run needs to run aptitude update to
> pick up the new package name. Running the update periodically
isn''t
> enough, but running an update on every catalog run is just overkill.
>
> Hope this explains my motives, and maybe someone has any more tips!
>
> Best regards,
> Martijn.
As it was said earlier if you have a ensure => latest you should
probably have (also) a cron job for updates.
For your case you may try a define like (using
http://forge.puppetlabs.com/ripienaar/concat ; read the comments in the
pp files)

define fastupdate_package(
     $reason,
     $date
)
{
     concat::fragment
     {"${name}_install":
         target  => "/var/log/fastupdate_package.log",
         order   => $date,
         content => "${date} Installed package ${name}
(${reason})",
     }
     package
     {$name:
     #... stuff
         require    => Exec["aptupdate"],
     }
}


when using you should also have included in a class something similar to

concat
{ "/var/log/fastupdate_package.log":
     notify => Exec["aptupdate"],
}
exec
{ "aptupdate":
     command => "/usr/bin/aptitude update":
     refreshonly => true,
}

This should create something like a log file (not an actual log file,
since the new data is not appended, but recreated when necessary). This
would actually create some chaos if used for normal packages, so I
highly recommend using this in a module that only involves your
packages, and for the rest of packages use the cron solution, which is
way way more cleaner than this.


Hope it helps, :)
Silviu