Search code examples
puppet

Puppet install package greater than & less than?


If I have the following it works fine:

package { 
  2klic-certificates>=1.0.3: ensure => installed,
}

But 2klic-certificates is from a custom repository where we also have beta versions. So I'd also like to put an upper limit. I'm trying:

package { 
  2klic-certificates>=1.0.3<1.1.0: ensure => installed,
}

This returns the error:

Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install 2klic-certificates>=1.0.3<1.1.0' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package 2klic-certificates>
Error: /Stage[main]/Main/Node[default]/Package[2klic-certificates>=1.0.3<1.1.0]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install 2klic-certificates>=1.0.3<1.1.0' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package 2klic-certificates>

I've also tried:

package { 
  2klic-certificates>=1.0.3 and <1.1.0: ensure => installed,
}

Looking through the documentation I don't see an option to explicitly specify a minimum and maximum version number. Is this possible?


Solution

  • I will leave this open as this answer isn't a full solution, but rather a workaround (confirmed to work on apt based systems).

    We had the freedom to control our package naming convention and combined this with wildcards. So for example:

    package { 
      2klic-certificates>=1.0.*: ensure => latest,
    }
    

    Will ensure that the latest package in the 1.0 section is installed.

    So If a node has version 1.0.1 and 1.0.3 is available and we have a beta version of 1.1.0, the above will make sure 1.0.3 is installed on our main nodes and ignore the beta version.

    As mentioned this is not a real solution as you can't always control the naming convention for versions. It works for my initial question but if you wanted between 1.0.1 and 1.1.5 for example it would essentially be useless.


    In which case I would recommend looking at the snippets posted by @MattSchuchard