Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Puppet to install some Python packages using pip. I'm using Puppet 2.7, so my package declarations look something like this:

package { "carbon": 
    require => Class["graphite::prereqs::install"],
    ensure  => latest,
    provider => pip,
}

The problem is that this package and the graphite-web package both seem to have a bug that makes it possible to install the same version multiple times using pip. So if I type in sudo pip install carbon multiple times, pip will install it every time. I believ this is a bug with the packages.

This bug seems to confuse Puppet too, because every time I provision my system, carbon and graphite-web are re-installed.

I'm therefore wondering if there's a way to work around this apparent packaging bug. I've tried the following:

package { "carbon": 
    require => Class["graphite::prereqs::install"],
    ensure  => latest,
    provider => pip,
    creates => "/opt/graphite/bin/carbon-cache.py",
}

...but I can't use creates. Is there another way I can tell the package declaration to look for a file before installing the package?

share|improve this question
add comment

3 Answers 3

Might want to use exec's creates parameter:

exec { "carbon":
    command => "pip install carbon",
    require => Class["graphite::prereqs::install"],
    creates => "/opt/graphite/bin/carbon-cache.py",
    path    => ["/usr/bin", "/usr/sbin"],
    timeout => 100,
  }
share|improve this answer
    
I think you can also use the onlyif parameter to do this. –  quanta Aug 11 '12 at 15:01
    
yes you can use only-if –  Mike Aug 12 '12 at 0:36
add comment

I haven't tested but try this:

file { "/opt/graphite/bin/carbon-cache.py":
    ensure => 'absent',
}

package { "carbon": 
    require => [ Class["graphite::prereqs::install"], 
                 File["/opt/graphite/bin/carbon-cache.py"]
               ]
    ensure  => latest,
    provider => pip,
}
share|improve this answer
    
This will cause the carbon-cache.py file to be removed each time, but the package will still be installed repeatedly. –  Handyman5 Aug 11 '12 at 8:36
add comment

I'd try using "ensure => installed" instead of "ensure => latest".

From the puppet type reference:

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. Valid values are present (also called installed), absent, purged, held, latest. Values can match /./.

I don't know how the pip provider is written, but I bet that if you use installed instead of latest, puppet will detect that the package is already installed and not try to install it again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.