-
-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathbootstrap.pp
More file actions
71 lines (67 loc) · 2.24 KB
/
bootstrap.pp
File metadata and controls
71 lines (67 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# @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
# @param http_proxy Proxy server to use for outbound connections.
#
# @example
# class { 'python::pip::bootstrap':
# version => 'pip',
# }
#
class python::pip::bootstrap (
Array[String[1]] $pip_lookup_path,
Enum['pip', 'pip3'] $version = 'pip',
Variant[Boolean, String] $manage_python = false,
Optional[Stdlib::HTTPUrl] $http_proxy = undef,
String[1] $exec_provider = 'shell',
) {
if $manage_python {
include python
} else {
$target_src_pip_path = $facts['os']['family'] ? {
'AIX' => '/opt/freeware/bin',
default => '/usr/bin'
}
$environ = $http_proxy ? {
undef => [],
default => $facts['os']['family'] ? {
'AIX' => ["http_proxy=${http_proxy}", "https_proxy=${http_proxy}"],
default => ["HTTP_PROXY=${http_proxy}", "HTTPS_PROXY=${http_proxy}"],
}
}
if $version == 'pip3' {
exec { 'bootstrap pip3':
command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python3',
environment => $environ,
unless => 'which pip3',
path => $pip_lookup_path,
require => Package['python3'],
provider => $exec_provider,
}
# 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',
environment => $environ,
unless => 'which pip',
path => $pip_lookup_path,
require => Package['python'],
provider => $exec_provider,
}
# 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'],
}
}
}
}