diff --git a/manifests/install.pp b/manifests/install.pp index e93388ed..e7b52347 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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::bootstrap' Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |> diff --git a/manifests/params.pp b/manifests/params.pp index d8e5d5d4..b0e095e5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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', diff --git a/manifests/pip/bootstrap.pp b/manifests/pip/bootstrap.pp new file mode 100644 index 00000000..ea3e70b7 --- /dev/null +++ b/manifests/pip/bootstrap.pp @@ -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'], + } + } + } +}