I am attempting to have puppet (0.25.5-1.el5) update an already installed package when a new yum repo gets installed.

The basic image we have has package X installed at version 1.1 by default. In the available repos, version 1.1. is the most recent. I am installing a new repo which has package X at version 1.8 available. I would like to have both the installation of the new repo and the update of package X happen simultaneously. The code I have is as follows:

class repo {
  yumrepo { "foorepo":
    descr    => 'the foo repo',
    baseurl  => 'http://path.to.foo/repos/centos/5/',
    enabled  => 1,
    gpgcheck => 0,

class package_x {
  package { "package_x":
    provider => "yum",
    ensure   => "latest",
    require  => Yumrepo["foorepo"]

where the node is defined as:

node default {
  include repo
  include package_x

What I see happen is that when I run it the first time, puppet recognises that a new repo must be installed but, because the package is already available in a current repo, assumes that package_x is already at the latest version. If I run it a second time, it is then able to recognise that this new repo means that package_x must be updated to version 1.8.

I have played around with the notify and subscribe parameters but they don't seem to be applicable to a class. It seems that Puppet is evaluating the required updates against the current setup and therefore must apply the new repo before it is able to 'know' that a new version of package_x is available.

Am I missing a simple solution to this type of dependency issue? Has anybody found a setup that would allow this type of dependency to force the update of the package?



As far as I understand, this is exactly what stages are for -- they let you group and order class executions. I use "stages" to update and configure APT at Debian servers, which should be very similar to what you are going to do with YUM.

First of all, you declare "yum" stage at top level (above "nodes"), so that classes in "yum" stage will be executed before "main" ones:

stage { 'yum' : before => Stage['main'] }

Then, you assign stage to the classes. You can do this right in your node definition:

node default {
  class { 'repo' : stage => yum }
  include package_x
  • Thanks for this - it works with puppet 2.6 which I am, unfortunately, not using. Since am using this for bootstrapping a machine, have incorporated the yum setup into the shell script until we can upgrade puppet to 2.6 (which has so many features that would make my life easeier!). – oldNoakes Jun 7 '11 at 0:35

The behavior you describe is not my own experience. Run puppet by hand, with --debug:

puppetd --debug --test

In this mode, it will show every command it executes. It should show the command it is using to verify whether the package is at its latest version, so you can check what the command is, and when it is being executed.

I have little experience handling servers with Yum, but using apt-get (Debian), it is necessary to run a command to refresh the list of packages after updating the source list (the equivalent of yum repos). So, in my configurations, updates to source list notify the exec of a package list refresh, and new packages depend on said (refreshonly) exec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.