Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move pip bootstrap into a seperate class #460

Merged
merged 5 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,7 @@
}

# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
exec { 'bootstrap pip':
command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python',
unless => 'which pip',
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
require => Package['python'],
}

# Puppet is opinionated about the pip command name
file { 'pip-python':
ensure => link,
path => '/usr/bin/pip-python',
target => '/usr/bin/pip',
require => Exec['bootstrap pip'],
}
include 'python::pip::boostrap'
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved

Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>

Expand Down
5 changes: 5 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
$use_epel = false
}

$pip_lookup_path = $facts['os']['family'] ? {
'AIX' => [ '/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/' ],
default => [ '/bin', '/usr/bin', '/usr/local/bin' ]
}

$gunicorn_package_name = $::osfamily ? {
'RedHat' => 'python-gunicorn',
default => 'gunicorn',
Expand Down
52 changes: 52 additions & 0 deletions manifests/pip/bootstrap.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# @summary allow to bootstrap pip when python is managed from other module
#
# @param version should be pip or pip3
# @param manage_python if python module will manage deps
#
# @example
# class { 'python::pip::bootstrap':
# version => 'pip',
# }
class python::pip::bootstrap (
Enum['pip', 'pip3'] $version = 'pip',
Variant[Boolean, String] $manage_python = false,
) inherits ::python::params {
if $manage_python {
include ::python
} else {
$target_src_pip_path = $facts['os']['family'] ? {
'AIX' => '/opt/freeware/bin',
default => '/usr/bin'
}
if $version == 'pip3' {
exec { 'bootstrap pip3':
command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python3',
unless => 'which pip3',
path => $python::params::pip_lookup_path,
require => Package['python3'],
}
# puppet is opinionated about the pip command name
file { 'pip3-python':
ensure => link,
path => '/usr/bin/pip3',
target => "${target_src_pip_path}/pip${::facts['python3_release']}",
require => Exec['bootstrap pip3'],
}
} else {
exec { 'bootstrap pip':
command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python',
unless => 'which pip',
path => $python::params::pip_lookup_path,
require => Package['python'],
}
# puppet is opinionated about the pip command name
file { 'pip-python':
ensure => link,
path => '/usr/bin/pip',
target => "${target_src_pip_path}/pip${::facts['python2_release']}",
require => Exec['bootstrap pip'],
}
}
}
}