Package control of the installed version of the package

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 execute the gem list after it starts, two versions of sass were 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, you need to install only 3.2.0.alpha.277 . It seems that the sass package sass met, but the compass package requires sass "~> 3.1".

How to make sure that only version 3.2.0.alpha.277 sass is installed?

+4
source share
1 answer

Interestingly, I ran this on a pretty clean Ubuntu 12.04 slide, and it only installed version 277.

Also I do not think the package resource can do this for you. You could handle it in exec, for example:

 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 can even wrap it as a specific 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', } 

this way you can reuse it to remove other specific versions of gem.

+4
source

Source: https://habr.com/ru/post/1492473/


All Articles