Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I believe that you can use the 'ensure' parameter to specify package version on the package resource.. You'll have to use the exact version string, which can be seen on a system where you the correct version installed by running puppet resource package packagename

ubuntu:~/puppet-jira$ puppet resource package | head -n 9
package { 'CFPropertyList':
  ensure => ['2.2.8'],
}
package { 'accountsservice':
  ensure => '0.6.40-2ubuntu5',
}
package { 'acl':
  ensure => '2.2.52-2',
}

And here's the relevant section from puppet describe package

- **ensure**
    What state the package should be in. On packaging systems that can
    retrieve new packages on their own, you can choose which package to
    retrieve by specifying a version number or `latest` as the ensure
    value. On packaging systems that manage configuration files separately
    from "normal" system files, you can uninstall config files by
    specifying `purged` as the ensure value. This defaults to `installed`.
    Valid values are `present` (also called `installed`), `absent`,
    `purged`, `held`, `latest`. Values can match `/./`.

I believe that you can use the 'ensure' parameter to specify package version on the package resource.. You'll have to use the exact version string, which can be seen on a system where you the correct version installed by running puppet resource package packagename

ubuntu:~/puppet-jira$ puppet resource package | head -n 9
package { 'CFPropertyList':
  ensure => ['2.2.8'],
}
package { 'accountsservice':
  ensure => '0.6.40-2ubuntu5',
}
package { 'acl':
  ensure => '2.2.52-2',
}

And here's the relevant section from puppet describe package

- **ensure**
    What state the package should be in. On packaging systems that can
    retrieve new packages on their own, you can choose which package to
    retrieve by specifying a version number or `latest` as the ensure
    value. On packaging systems that manage configuration files separately
    from "normal" system files, you can uninstall config files by
    specifying `purged` as the ensure value. This defaults to `installed`.
    Valid values are `present` (also called `installed`), `absent`,
    `purged`, `held`, `latest`. Values can match `/./`.

------------- EDIT -----------------

I just tried it out locally, and it seems to behave as I expected

ubuntu:~/puppet-jira$ apt-cache madison mysql-client
mysql-client | 5.6.30-0ubuntu0.15.10.1 | http://us.archive.ubuntu.com/ubuntu/ wily-updates/main amd64 Packages
mysql-client | 5.6.30-0ubuntu0.15.10.1 | http://security.ubuntu.com/ubuntu/ wily-security/main amd64 Packages
mysql-client | 5.6.25-0ubuntu1 | http://us.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
 mysql-5.6 | 5.6.25-0ubuntu1 | http://us.archive.ubuntu.com/ubuntu/ wily/main Sources
 mysql-5.6 | 5.6.30-0ubuntu0.15.10.1 | http://us.archive.ubuntu.com/ubuntu/ wily-updates/main Sources
 mysql-5.6 | 5.6.30-0ubuntu0.15.10.1 | http://security.ubuntu.com/ubuntu/ wily-security/main Sources
ubuntu:~/puppet-jira$ sudo puppet apply -e "package{ 'mysql-client': ensure => '5.6.30-0ubuntu0.15.10.1',}" # 5.6.25-0ubuntu1
Notice: Compiled catalog for ubuntu in environment production in 0.05 seconds
Notice: /Stage[main]/Main/Package[mysql-client]/ensure: created
Notice: Applied catalog in 27.76 seconds
ubuntu:~/puppet-jira$ puppet resource package mysql-client
package { 'mysql-client':
  ensure => '5.6.30-0ubuntu0.15.10.1',
}
ubuntu:~/puppet-jira$ sudo puppet apply -e "package{ 'mysql-client': ensure => '5.6.25-0ubuntu1',}"
Notice: Compiled catalog for ubuntu in environment production in 0.05 seconds
Notice: /Stage[main]/Main/Package[mysql-client]/ensure: ensure changed '5.6.30-0ubuntu0.15.10.1' to '5.6.25-0ubuntu1'
Notice: Applied catalog in 1.67 seconds
ubuntu:~/puppet-jira$ puppet resource package mysql-client
package { 'mysql-client':
  ensure => '5.6.25-0ubuntu1',
}

I believe that you can use the 'ensure' parameter to specify package version on the package resource.. You'll have to use the exact version string, which can be seen on a system where you the correct version installed by running puppet resource package packagename

ubuntu:~/puppet-jira$ puppet resource package | head -n 9
package { 'CFPropertyList':
  ensure => ['2.2.8'],
}
package { 'accountsservice':
  ensure => '0.6.40-2ubuntu5',
}
package { 'acl':
  ensure => '2.2.52-2',
}

And here's the relevant section from puppet describe package

- **ensure**
    What state the package should be in. On packaging systems that can
    retrieve new packages on their own, you can choose which package to
    retrieve by specifying a version number or `latest` as the ensure
    value. On packaging systems that manage configuration files separately
    from "normal" system files, you can uninstall config files by
    specifying `purged` as the ensure value. This defaults to `installed`.
    Valid values are `present` (also called `installed`), `absent`,
    `purged`, `held`, `latest`. Values can match `/./`.

------------- EDIT -----------------

I just tried it out locally, and it seems to behave as I expected

ubuntu:~/puppet-jira$ apt-cache madison mysql-client
mysql-client | 5.6.30-0ubuntu0.15.10.1 | http://us.archive.ubuntu.com/ubuntu/ wily-updates/main amd64 Packages
mysql-client | 5.6.30-0ubuntu0.15.10.1 | http://security.ubuntu.com/ubuntu/ wily-security/main amd64 Packages
mysql-client | 5.6.25-0ubuntu1 | http://us.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
 mysql-5.6 | 5.6.25-0ubuntu1 | http://us.archive.ubuntu.com/ubuntu/ wily/main Sources
 mysql-5.6 | 5.6.30-0ubuntu0.15.10.1 | http://us.archive.ubuntu.com/ubuntu/ wily-updates/main Sources
 mysql-5.6 | 5.6.30-0ubuntu0.15.10.1 | http://security.ubuntu.com/ubuntu/ wily-security/main Sources
ubuntu:~/puppet-jira$ sudo puppet apply -e "package{ 'mysql-client': ensure => '5.6.30-0ubuntu0.15.10.1',}" # 5.6.25-0ubuntu1
'5.6.30-0ubuntu0.15.10.1',}"
Notice: Compiled catalog for ubuntu in environment production in 0.05 seconds
Notice: /Stage[main]/Main/Package[mysql-client]/ensure: created
Notice: Applied catalog in 27.76 seconds
ubuntu:~/puppet-jira$ puppet resource package mysql-client
package { 'mysql-client':
  ensure => '5.6.30-0ubuntu0.15.10.1',
}
ubuntu:~/puppet-jira$ sudo puppet apply -e "package{ 'mysql-client': ensure => '5.6.25-0ubuntu1',}"
Notice: Compiled catalog for ubuntu in environment production in 0.05 seconds
Notice: /Stage[main]/Main/Package[mysql-client]/ensure: ensure changed '5.6.30-0ubuntu0.15.10.1' to '5.6.25-0ubuntu1'
Notice: Applied catalog in 1.67 seconds
ubuntu:~/puppet-jira$ puppet resource package mysql-client
package { 'mysql-client':
  ensure => '5.6.25-0ubuntu1',
}