5

Using puppet I want to update packages on my (CentOS 5 & 6 servers) in a controlled way. Therefore I don't want to use ensure=>latest but rather ensure=>3.0.1-1.

Example:

class puppet::installation inherits puppet {
        package { "puppet":
            ensure => "3.0.1-1",
        }
}

The update works alright but puppet agent keeps complaining that there is a difference:

/Stage[main]/Puppet::Installation/Package[puppet]/ensure: current_value 3.0.1-1.el6, should be 3.0.1-1 (noop)

I can solve this by changing the ensure rule to 3.0.1-1.el6 but than that won't work on CentOS 5.

Is there a short/clean way to solve this or do I have to write to seperate, os-releaseversion dependant rules.

I have been googling for a solution but didn't find anything pertaining to this particular question.

Any suggestion or reference to a relevant example would be appreciated.

1
  • 1
    personally i use ensure => installed, and mirror the repos. That way you control what "latest" is, and when to update to it.
    – Sirex
    Nov 24, 2012 at 19:09

3 Answers 3

4

You would have to set a variable with a case statement, sort of like this:

class puppet::installation inherits puppet {

        case $::operatingsystemrelease {
            '5':     { $puppet_ver = '3.0.1-1'}
            default: { $puppet_ver = '3.0.1-1.el6'}
        }

        package { 'puppet':
            ensure => $puppet_ver,
        }
}

However, it's a better design to use a params.pp file for this sort of logic. Read about params.pp here: http://www.example42.com/?q=understandExample42PuppetModules

2

Puppet really doesn't have any functionality for this yet (though they really need it).

You can use the yum-versionlock yum plugin to lock specific RPM packages at specific versions, and then use puppet to control the versionlock configuration.

For some other workarounds, see this related question.

1

Actually, I was able to use the wildcard character to install a specific version of Python regardless of operating system. My package code for python is as follows.

package {
    "python-dev": ensure => "2.7.3*";
    "python-setuptools": ensure => installed;
    "python-pip": ensure => installed;
    "libxml2-dev": ensure => installed;
    "libxslt-dev": ensure => installed;
}

By using the 2.7.3* as the ensure version, it installed python 2.7.3-0ubuntu2.2 on my vagrant VM. I'm using Puppet version 2.7.19.

2
  • Check out the puppet style guide: docs.puppetlabs.com/guides/style_guide.html#compression
    – robbyt
    Dec 20, 2014 at 2:54
  • This is obviously a very old Q&A, but my experience in 2021 is that, although using a wildcarded version number will work to install the package, puppet 5.x treats the wildcarded version number as a literal. This means that on every agent run, puppet will attempt to re-install the package. It's like apt recognises the * and does the right thing, but puppet doesn't.
    – Jimadine
    Feb 19, 2021 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .