On Tue, Aug 31, 2010 at 7:03 AM, Martijn Grendelman
<mart...@grendelman.net> wrote:
> 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?

Why do you want to run this before every package install? That will
add a fair bit of overhead. I don't quite understand the desire to run
before every package install, and yet not simply have it run once
before all package installs.

We've used two approaches, both using our package::apt::update class
which runs apt-get update/upgrade/dpkg --configure -a etc.

1) Resource defaults:

In the global scope, set a resource default for package to require the
package::apt::update class
The downside is that if you wish to set an additional require for a
specific package, you need to remember to include the global default
as well.

2) Defined types:

Define a type much like yours that has the same require on the package
resource definition inside the defined type.
The downside is that you are no longer just using 'package' resources,
which makes the use of other people's modules difficult.
The upside is that we have a similar defined type 'apt_repo' that sets
up repositories. With appropriate use of require in apt_package and
before in apt_repo, you know your repositories are being laid down
before apt-get update etc get run, and that the packages are installed
afterwards.

Run stages make this a bit simpler, but you can achieve the same
functionality without them.

>
> 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.
>
>



-- 
nigel

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to