Puppet - controlling installed package version
puppet, rubygems
Solution
Interestingly I ran this on a pretty much clean slate of Ubuntu 12.04 and it only installed the 277 version.
Also I don't think that the package resource can do this for you. You could handle it in an exec though, like:
exec { 'remove-sass-3.3.0.alpha.212':
command => 'gem uninstall sass -v=3.3.0.alpha.212',
unless => 'test `gem list --local | grep -q 3.3.0.alpha.212; echo $?` -ne 0',
path => ['/usr/bin', '/bin'],
}
You could even wrap it up as a defined type:
define remove-gem ($version) {
exec { "remove-gem-${name}-version-${version}":
command => "gem uninstall ${name} -v=${version}",
unless => "test `gem list --local | grep -q \"${name}.*${version}\"; echo $?` -ne 0",
path => ['/usr/bin', '/bin'],
}
}
remove-gem {'sass':
version => '3.3.0.alpha.212',
}
that way you can reuse it to remove other particular gem versions.
Problem
I have the following: ``` class compass { package { 'ruby-dev': ensure => installed, } package { ["rubygems"]: ensure => 'installed' } package { ['sass']: ensure => '3.2.0.alpha.277', provider => 'gem', require => Package['rubygems'] }~> package { ['compass']: ensure => '0.12.2', provider => 'gem', require => Package['rubygems'] } } ``` When I do `gem list` after it has run, two versions of `sass` has been installed: ``` # gem list *** LOCAL GEMS *** chunky_png (1.2.8) compass (0.12.2) ffi (1.9.0) fssm (0.2.10) listen (1.1.6) rake (10.1.0) rb-fsevent (0.9.3) rb-inotify (0.9.0) rb-kqueue (0.2.0) sass (3.3.0.alpha.212, 3.2.0.alpha.277) zurb-foundation (3.0.6) ``` In order for my code to run, only `3.2.0.alpha.277` should be installed. It seems that the requirement from the `sass` package is fulfilled, but that the `compass` package requires sass "~> 3.1". How do I make sure that only the `3.2.0.alpha.277` version of sass is installed?