Puppet : Specifying a version of a package to install Puppet : Specifying a version of a package to install php php

Puppet : Specifying a version of a package to install


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' ,}


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 /tmpfile { '/tmp/pgp-keys':        ensure  => directory,        recurse => true,        source  => 'puppet:///modules/modulename/pgp',}# add any keys that you needexec { '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 repositoryfile { '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 listexec { '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 opsmasonpackage { 'cassandra':        ensure  => '1.2.0',        require => Exec['apt-get update'],}