|
| 1 | +# |
| 2 | +# @summary allow to bootstrap pip when python is managed from other module |
| 3 | +# |
| 4 | +# @param version should be pip or pip3 |
| 5 | +# @param manage_python if python module will manage deps |
| 6 | +# |
| 7 | +# @example |
| 8 | +# class { 'python::pip::bootstrap': |
| 9 | +# version => 'pip', |
| 10 | +# } |
| 11 | +class python::pip::bootstrap ( |
| 12 | + Enum['pip', 'pip3'] $version = 'pip', |
| 13 | + Variant[Boolean, String] $manage_python = false, |
| 14 | +) inherits ::python::params { |
| 15 | + if $manage_python { |
| 16 | + include ::python |
| 17 | + } else { |
| 18 | + $target_src_pip_path = $facts['os']['family'] ? { |
| 19 | + 'AIX' => '/opt/freeware/bin', |
| 20 | + default => '/usr/bin' |
| 21 | + } |
| 22 | + if $version == 'pip3' { |
| 23 | + exec { 'bootstrap pip3': |
| 24 | + command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python3', |
| 25 | + unless => 'which pip3', |
| 26 | + path => $python::params::pip_lookup_path, |
| 27 | + require => Package['python3'], |
| 28 | + } |
| 29 | + # puppet is opinionated about the pip command name |
| 30 | + file { 'pip3-python': |
| 31 | + ensure => link, |
| 32 | + path => '/usr/bin/pip3', |
| 33 | + target => "${target_src_pip_path}/pip${::facts['python3_release']}", |
| 34 | + require => Exec['bootstrap pip3'], |
| 35 | + } |
| 36 | + } else { |
| 37 | + exec { 'bootstrap pip': |
| 38 | + command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python', |
| 39 | + unless => 'which pip', |
| 40 | + path => $python::params::pip_lookup_path, |
| 41 | + require => Package['python'], |
| 42 | + } |
| 43 | + # puppet is opinionated about the pip command name |
| 44 | + file { 'pip-python': |
| 45 | + ensure => link, |
| 46 | + path => '/usr/bin/pip', |
| 47 | + target => "${target_src_pip_path}/pip${::facts['python2_release']}", |
| 48 | + require => Exec['bootstrap pip'], |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | +} |
0 commit comments