|
3 | 3 | # |
4 | 4 | # @param version should be pip or pip3 |
5 | 5 | # @param manage_python if python module will manage deps |
| 6 | +# @param http_proxy Proxy server to use for outbound connections. |
6 | 7 | # |
7 | 8 | # @example |
8 | 9 | # class { 'python::pip::bootstrap': |
|
11 | 12 | class python::pip::bootstrap ( |
12 | 13 | Enum['pip', 'pip3'] $version = 'pip', |
13 | 14 | Variant[Boolean, String] $manage_python = false, |
| 15 | + Optional[Stdlib::HTTPUrl] $http_proxy = undef, |
14 | 16 | ) inherits ::python::params { |
15 | 17 | if $manage_python { |
16 | 18 | include python |
|
19 | 21 | 'AIX' => '/opt/freeware/bin', |
20 | 22 | default => '/usr/bin' |
21 | 23 | } |
| 24 | + |
| 25 | + $environ = $http_proxy ? { |
| 26 | + undef => [], |
| 27 | + default => $facts['os']['family'] ? { |
| 28 | + 'AIX' => [ "http_proxy=${http_proxy}", "https_proxy=${http_proxy}" ], |
| 29 | + default => [ "HTTP_PROXY=${http_proxy}", "HTTPS_PROXY=${http_proxy}" ], |
| 30 | + } |
| 31 | + } |
| 32 | + |
22 | 33 | if $version == 'pip3' { |
23 | 34 | 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'], |
| 35 | + command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python3', |
| 36 | + environment => $environ, |
| 37 | + unless => 'which pip3', |
| 38 | + path => $python::params::pip_lookup_path, |
| 39 | + require => Package['python3'], |
28 | 40 | } |
29 | 41 | # puppet is opinionated about the pip command name |
30 | 42 | file { 'pip3-python': |
31 | 43 | ensure => link, |
32 | 44 | path => '/usr/bin/pip3', |
33 | | - target => "${target_src_pip_path}/pip${::facts['python3_release']}", |
| 45 | + target => "${target_src_pip_path}/pip${facts['python3_release']}", |
34 | 46 | require => Exec['bootstrap pip3'], |
35 | 47 | } |
36 | 48 | } 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 | | - } |
| 49 | + exec { 'bootstrap pip': |
| 50 | + command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python', |
| 51 | + environment => $environ, |
| 52 | + unless => 'which pip', |
| 53 | + path => $python::params::pip_lookup_path, |
| 54 | + require => Package['python'], |
| 55 | + } |
| 56 | + # puppet is opinionated about the pip command name |
| 57 | + file { 'pip-python': |
| 58 | + ensure => link, |
| 59 | + path => '/usr/bin/pip', |
| 60 | + target => "${target_src_pip_path}/pip${facts['python2_release']}", |
| 61 | + require => Exec['bootstrap pip'], |
| 62 | + } |
50 | 63 | } |
51 | 64 | } |
52 | 65 | } |
0 commit comments