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

Martijn Grendelman
Tue, 31 Aug 2010 14:03:35 -0000

Hi,

For the past week, I have been trying to figure out the best way to do
package management with Puppet on an Ubuntu system. I have studied many
solutons I found on the web, but none of them seem to do exactly what I want.

Among other things, I have tried everything that is discussed here:
http://groups.google.com/group/puppet-users/browse_thread/thread/af7349171a5821a4/db96b809c97f6006

but none of that really works.

What I would like, is for Puppet to run `aptitude update` before it
installs or upgrades packages. That doesn''t seem out of the ordinary to
me, but I can''t make it work in Puppet.

The approach I like best, is this one:

    class apt-update {
        exec { "/usr/bin/aptitude update":
            refreshonly => true,
        }
    }

    define apt_package($ensure="latest") {
        include apt-update
        package { $name:
            ensure  => $ensure,
            require => Class["apt-update"],
        }
    }

    apt_package { "foo":
    }

but that doesn''t work, it doesn''t run apt-update before
installing ''foo'',
because of the "refreshonly => true". If I remove it, it works, but
then
`aptitude update` is run on /every/ Puppet run, which is worse than not
running it at all.

Is it at all possible to achieve what I want with Puppet? If so, how?

I have tried to fiddle around with the new run stages feature, but that
got me in a circular dependency mess I couldn''t get out of.

Desperately hoping for hints...

Best regards,
Martijn.