Ask Your Question
0

How to install Python packages with pip2?

asked 2014-11-09 03:31:47 -0500

l0b0 gravatar image

updated 2014-11-09 03:46:54 -0500

I've got the following two manifests:

class python2 {
  package { 'python2-pip':
    ensure => installed,
  }
}

and

class vcard_validator {
  require python2

  package { 'vcard':
    ensure   => installed,
    provider => pip,
  }
}

But Puppet doesn't seem to know of the resulting pip2 command:

==> default: Notice: /Stage[main]/Python2/Package[python2-pip]/ensure: ensure changed 'purged' to 'present'
[...]
==> default: Debug: Prefetching pip resources for package
==> default: Error: Could not set 'present' on ensure: Could not locate the pip command. at 7:/tmp/vagrant-puppet-3/modules-0/vcard_validator/manifests/init.pp
==> default: Error: Could not set 'present' on ensure: Could not locate the pip command. at 7:/tmp/vagrant-puppet-3/modules-0/vcard_validator/manifests/init.pp
==> default: Wrapped exception:
==> default: Could not locate the pip command.
==> default: Error: /Stage[main]/Vcard_validator/Package[vcard]/ensure: change from absent to present failed: Could not set 'present' on ensure: Could not locate the pip command. at 7:/tmp/vagrant-puppet-3/modules-0/vcard_validator/manifests/init.pp

Also, pip on my platform (Arch Linux) would be Python 3-specific, and the vcard package is Python 2 only, so I can't simply install python-pip.

So there's a two-part question:

  1. How do I make Puppet aware of pip2? Currently there seems to be no install_options feature for the pip provider. I guess a custom provider should be possible, but I'm surprised to see that it doesn't seem to exist already.
  2. If multiple pip versions are available, how do I force Puppet to use a specific one?
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-09 05:04:03 -0500

l0b0 gravatar image

updated 2014-11-09 09:39:58 -0500

A custom package provider in modules/my_module/lib/puppet/provider/package/pip2.rb does the job:

Puppet::Type.type(:package).provide(:pip2, :parent => :pip, :source => :pip) do
  def self.cmd
    "pip2"
  end
end
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-09 03:31:47 -0500

Seen: 1,185 times

Last updated: Nov 09 '14