272
|
1 # @api private
|
|
2 # @summary Installs core python packages
|
|
3 #
|
|
4 # @example
|
|
5 # include python::install
|
|
6 #
|
|
7 class python::install {
|
|
8 $python = $python::version ? {
|
|
9 'system' => 'python',
|
|
10 'pypy' => 'pypy',
|
|
11 /\A(python[23]\.[0-9]+)/ => $1,
|
|
12 /\A(python)?([0-9]+)/ => "python${2}",
|
|
13 /\Arh-python[0-9]{2}/ => $python::version,
|
|
14 default => "python${python::version}",
|
|
15 }
|
|
16
|
|
17 $pythondev = $facts['os']['family'] ? {
|
387
|
18 'AIX' => "${python}-devel",
|
|
19 'Debian' => "${python}-dev",
|
|
20 'FreeBSD' => undef,
|
|
21 'Gentoo' => undef,
|
|
22 'RedHat' => "${python}-devel",
|
|
23 'Suse' => "${python}-devel",
|
272
|
24 }
|
|
25
|
|
26 $pip_ensure = $python::pip ? {
|
|
27 true => 'present',
|
|
28 false => 'absent',
|
|
29 default => $python::pip,
|
|
30 }
|
|
31
|
387
|
32 $dev_ensure = $python::dev ? {
|
272
|
33 true => 'present',
|
|
34 false => 'absent',
|
387
|
35 default => $python::dev,
|
272
|
36 }
|
|
37
|
387
|
38 if $python::manage_python_package {
|
|
39 package { 'python':
|
|
40 ensure => $python::ensure,
|
|
41 name => $python,
|
272
|
42 }
|
|
43 }
|
|
44
|
|
45 case $python::provider {
|
|
46 'pip': {
|
387
|
47 if $python::manage_pip_package {
|
|
48 package { 'pip':
|
|
49 ensure => $pip_ensure,
|
|
50 require => Package['python'],
|
|
51 }
|
272
|
52 }
|
|
53
|
|
54 if $pythondev {
|
|
55 package { 'python-dev':
|
|
56 ensure => $dev_ensure,
|
|
57 name => $pythondev,
|
|
58 }
|
|
59 }
|
|
60
|
|
61 # Respect the $pip_ensure setting
|
|
62 unless $pip_ensure == 'absent' {
|
|
63 # Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
|
387
|
64 include python::pip::bootstrap
|
272
|
65
|
|
66 Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>
|
|
67
|
|
68 Package <| title == 'pip' |> {
|
|
69 name => 'pip',
|
|
70 provider => 'pip',
|
|
71 }
|
|
72 }
|
|
73 }
|
|
74 'scl': {
|
|
75 # SCL is only valid in the RedHat family. If RHEL, package must be
|
|
76 # enabled using the subscription manager outside of puppet. If CentOS,
|
|
77 # the centos-release-SCL will install the repository.
|
|
78 if $python::manage_scl {
|
|
79 $install_scl_repo_package = $facts['os']['name'] ? {
|
|
80 'CentOS' => 'present',
|
|
81 default => 'absent',
|
|
82 }
|
|
83
|
|
84 package { 'centos-release-scl':
|
|
85 ensure => $install_scl_repo_package,
|
|
86 before => Package['scl-utils'],
|
|
87 }
|
387
|
88
|
272
|
89 package { 'scl-utils':
|
|
90 ensure => 'present',
|
|
91 before => Package['python'],
|
|
92 }
|
|
93
|
|
94 Package['scl-utils'] -> Package["${python}-scldevel"]
|
|
95
|
|
96 if $pip_ensure != 'absent' {
|
|
97 Package['scl-utils'] -> Exec['python-scl-pip-install']
|
|
98 }
|
|
99 }
|
|
100
|
|
101 package { "${python}-scldevel":
|
|
102 ensure => $dev_ensure,
|
|
103 }
|
387
|
104
|
272
|
105 if $pip_ensure != 'absent' {
|
|
106 exec { 'python-scl-pip-install':
|
|
107 command => "${python::exec_prefix}easy_install pip",
|
|
108 path => ['/usr/bin', '/bin'],
|
|
109 creates => "/opt/rh/${python::version}/root/usr/bin/pip",
|
|
110 }
|
|
111 }
|
|
112 }
|
|
113 'rhscl': {
|
|
114 # rhscl is RedHat SCLs from softwarecollections.org
|
|
115 if $python::rhscl_use_public_repository {
|
|
116 $scl_package = "rhscl-${python::version}-epel-${facts['os']['release']['major']}-${facts['os']['architecture']}"
|
387
|
117
|
272
|
118 package { $scl_package:
|
|
119 source => "https://www.softwarecollections.org/en/scls/rhscl/${python::version}/epel-${facts['os']['release']['major']}-${facts['os']['architecture']}/download/${scl_package}.noarch.rpm",
|
|
120 provider => 'rpm',
|
|
121 tag => 'python-scl-repo',
|
|
122 }
|
|
123 }
|
|
124
|
|
125 Package <| title == 'python' |> {
|
|
126 tag => 'python-scl-package',
|
|
127 }
|
|
128
|
|
129 Package <| title == 'virtualenv' |> {
|
|
130 name => "${python}-python-virtualenv",
|
|
131 }
|
|
132
|
|
133 package { "${python}-scldevel":
|
|
134 ensure => $dev_ensure,
|
|
135 tag => 'python-scl-package',
|
|
136 }
|
|
137
|
|
138 package { "${python}-python-pip":
|
|
139 ensure => $pip_ensure,
|
|
140 tag => 'python-pip-package',
|
|
141 }
|
|
142
|
|
143 if $python::rhscl_use_public_repository {
|
|
144 Package <| tag == 'python-scl-repo' |>
|
|
145 -> Package <| tag == 'python-scl-package' |>
|
|
146 }
|
|
147
|
387
|
148 Package <| tag == 'python-scl-package' |> -> Package <| tag == 'python-pip-package' |>
|
272
|
149 }
|
|
150 'anaconda': {
|
|
151 $installer_path = '/var/tmp/anaconda_installer.sh'
|
|
152
|
|
153 file { $installer_path:
|
|
154 source => $python::anaconda_installer_url,
|
|
155 mode => '0700',
|
|
156 }
|
|
157 -> exec { 'install_anaconda_python':
|
|
158 command => "${installer_path} -b -p ${python::anaconda_install_path}",
|
|
159 creates => $python::anaconda_install_path,
|
|
160 logoutput => true,
|
|
161 }
|
|
162 -> exec { 'install_anaconda_virtualenv':
|
|
163 command => "${python::anaconda_install_path}/bin/pip install virtualenv",
|
|
164 creates => "${python::anaconda_install_path}/bin/virtualenv",
|
|
165 }
|
|
166 }
|
|
167 default: {
|
|
168 case $facts['os']['family'] {
|
|
169 'AIX': {
|
|
170 if String($python::version) =~ /^python3/ {
|
|
171 class { 'python::pip::bootstrap':
|
387
|
172 version => 'pip3',
|
272
|
173 }
|
|
174 } else {
|
387
|
175 if $python::manage_pip_package {
|
|
176 package { 'python-pip':
|
|
177 ensure => $pip_ensure,
|
|
178 require => Package['python'],
|
|
179 provider => 'yum',
|
|
180 }
|
272
|
181 }
|
|
182 }
|
387
|
183
|
272
|
184 if $pythondev {
|
|
185 package { 'python-dev':
|
|
186 ensure => $dev_ensure,
|
|
187 name => $pythondev,
|
|
188 alias => $pythondev,
|
|
189 provider => 'yum',
|
|
190 }
|
|
191 }
|
|
192 }
|
|
193 default: {
|
387
|
194 if $python::manage_pip_package {
|
|
195 package { 'pip':
|
|
196 ensure => $pip_ensure,
|
|
197 require => Package['python'],
|
|
198 }
|
272
|
199 }
|
387
|
200
|
272
|
201 if $pythondev {
|
|
202 package { 'python-dev':
|
|
203 ensure => $dev_ensure,
|
|
204 name => $pythondev,
|
|
205 alias => $pythondev,
|
|
206 }
|
|
207 }
|
|
208 }
|
|
209 }
|
|
210
|
387
|
211 if $facts['os']['family'] == 'RedHat' {
|
|
212 if $pip_ensure != 'absent' and $python::use_epel and ($python::manage_pip_package or $python::manage_python_package) {
|
|
213 require epel
|
272
|
214 }
|
|
215 }
|
|
216
|
|
217 if String($python::version) =~ /^python3/ {
|
|
218 $pip_category = undef
|
387
|
219 $pip_package = "${python}-pip"
|
272
|
220 $pip_provider = $python.regsubst(/^.*python3\.?/,'pip3.').regsubst(/\.$/,'')
|
387
|
221 } elsif ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '8') >= 0) {
|
|
222 $pip_category = undef
|
|
223 $pip_package = 'python3-pip'
|
|
224 $pip_provider = pip3
|
272
|
225 } elsif ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '7') >= 0) {
|
|
226 $pip_category = undef
|
387
|
227 $pip_package = 'python2-pip'
|
272
|
228 $pip_provider = pip2
|
387
|
229 } elsif $facts['os']['family'] == 'FreeBSD' {
|
|
230 $pip_category = undef
|
|
231 $pip_package = "py${python::version}-pip"
|
|
232 $pip_provider = 'pip'
|
272
|
233 } elsif $facts['os']['family'] == 'Gentoo' {
|
|
234 $pip_category = 'dev-python'
|
387
|
235 $pip_package = 'pip'
|
272
|
236 $pip_provider = 'pip'
|
387
|
237 } elsif ($facts['os']['name'] == 'Ubuntu') and (versioncmp($facts['os']['release']['major'], '20.04') >= 0) {
|
|
238 $pip_category = undef
|
|
239 $pip_package = 'python3-pip'
|
|
240 $pip_provider = 'pip3'
|
|
241 } elsif ($facts['os']['name'] == 'Debian') and (versioncmp($facts['os']['release']['major'], '11') >= 0) {
|
|
242 $pip_category = undef
|
|
243 $pip_package = 'python3-pip'
|
|
244 $pip_provider = 'pip3'
|
272
|
245 } else {
|
|
246 $pip_category = undef
|
387
|
247 $pip_package = 'python-pip'
|
272
|
248 $pip_provider = 'pip'
|
|
249 }
|
|
250
|
|
251 Package <| title == 'pip' |> {
|
|
252 name => $pip_package,
|
|
253 category => $pip_category,
|
|
254 }
|
|
255 }
|
|
256 }
|
|
257
|
|
258 if $python::manage_gunicorn {
|
|
259 $gunicorn_ensure = $python::gunicorn ? {
|
|
260 true => 'present',
|
|
261 false => 'absent',
|
|
262 default => $python::gunicorn,
|
|
263 }
|
|
264
|
|
265 package { 'gunicorn':
|
|
266 ensure => $gunicorn_ensure,
|
|
267 name => $python::gunicorn_package_name,
|
|
268 }
|
|
269 }
|
|
270 }
|