Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppet : Specifying a version of a package to install

Apparently this is not possible, but I can't believe that I'm the only one who need it.

I want to specify the version of php to install because I'm working on an old project requiring php 5.2.

Actually my VM is based on Oneiric with php 5.3

Do you have any solution to do this ?

like image 407
JulienD Avatar asked Jul 23 '12 14:07

JulienD


People also ask

How do I specify a version of a package?

Using either a caret ( ^ ) or a tilde ( ~ ) we can specify the latest minor or patch version, respectively. This way you can specify a compatible package version, but still get the latest.

Which resource is used in puppet to install software?

adminfile. A file containing package defaults for installing packages. This attribute is only used on Solaris. Its value should be a path to a local file stored on the target system.

Who is the default provider for package resource type?

One of the many providers for the package resource type is Oracle Solaris pkg. Note that the sun provider for the package resource type is only for Oracle Solaris 10 packages and earlier. One of the many providers for the service resource type is Oracle Solaris smf.


2 Answers

You can specify a version:

package { 'php' :   ensure => '5.2' , } 

However, if that version of PHP RPM/Deb/package isn't available in your upstream repo, then you'll want to either:

  1. Find an alternate repo that has that package, and add it to your repo list
  2. Set up your own repo with the package
  3. Install from your filesystem, by providing a path to the package:

    package { 'php' :   ensure => '5.2' ,   source => '/some/path/to/php-5.2.rpm' , } 
like image 146
opsmason Avatar answered Sep 21 '22 00:09

opsmason


This is pretty close to how I use custom apt repositories in puppet with their gpg keys

# put downloaded pgp keys into modulename/files/pgp/ # this will copy them all into /tmp file { '/tmp/pgp-keys':         ensure  => directory,         recurse => true,         source  => 'puppet:///modules/modulename/pgp', }  # add any keys that you need exec { 'apt-key add':         command     => '/usr/bin/apt-key add /tmp/pgp-keys/number1.gpg.key &&/                         /usr/bin/apt-key add /tmp/pgp-keys/number2.gpg.key',         subscribe   => File['/tmp/pgp-keys'],         refreshonly => true, }  # make sure you add your custom apt repository file { 'cassandra.sources.list':         ensure  => 'present',         path    => '/etc/apt/sources.list.d/cassandra.sources.list',         source  => 'puppet:///modules/modulename/cassandra.sources.list',         require => Exec['apt-key add'], }  # update your package list exec { 'apt-get update':         command => '/usr/bin/apt-get update',         require => File['cassandra.sources.list'], }  # Install your specific package - I haven't actually used this yet,  # based on answer by opsmason package { 'cassandra':         ensure  => '1.2.0',         require => Exec['apt-get update'], } 
like image 38
StuartW Avatar answered Sep 21 '22 00:09

StuartW