|
1 | | -# == Define: python::install |
| 1 | +# == Class: python::install |
2 | 2 | # |
3 | 3 | # Installs core python packages |
4 | 4 | # |
|
11 | 11 | # Sergey Stankevich |
12 | 12 | # Ashley Penney |
13 | 13 | # Fotis Gimian |
| 14 | +# Garrett Honeycutt <[email protected]> |
14 | 15 | # |
15 | | - |
16 | 16 | class python::install { |
17 | 17 |
|
18 | 18 | $python = $::python::version ? { |
|
23 | 23 |
|
24 | 24 | $pythondev = $::osfamily ? { |
25 | 25 | 'RedHat' => "${python}-devel", |
26 | | - 'Debian' => "${python}-dev" |
| 26 | + 'Debian' => "${python}-dev", |
| 27 | + 'Suse' => "${python}-devel", |
| 28 | + } |
| 29 | + |
| 30 | + $python_virtualenv = $::lsbdistcodename ? { |
| 31 | + 'jessie' => 'virtualenv', |
| 32 | + default => 'python-virtualenv', |
27 | 33 | } |
28 | 34 |
|
29 | 35 | # pip version: use only for installation via os package manager! |
|
55 | 61 | package { 'pip': ensure => latest, provider => pip } |
56 | 62 | package { "python==${python::version}": ensure => latest, provider => pip } |
57 | 63 | } |
| 64 | + scl: { |
| 65 | + # SCL is only valid in the RedHat family. If RHEL, package must be |
| 66 | + # enabled using the subscription manager outside of puppet. If CentOS, |
| 67 | + # the centos-release-SCL will install the repository. |
| 68 | + $install_scl_repo_package = $::operatingsystem ? { |
| 69 | + 'CentOS' => present, |
| 70 | + default => absent, |
| 71 | + } |
| 72 | + |
| 73 | + package { 'centos-release-SCL': |
| 74 | + ensure => $install_scl_repo_package, |
| 75 | + before => Package['scl-utils'], |
| 76 | + } |
| 77 | + package { 'scl-utils': ensure => latest, } |
| 78 | + package { $::python::version: |
| 79 | + ensure => present, |
| 80 | + require => Package['scl-utils'], |
| 81 | + } |
| 82 | + # This gets installed as a dependency anyway |
| 83 | + # package { "${python::version}-python-virtualenv": |
| 84 | + # ensure => $venv_ensure, |
| 85 | + # require => Package['scl-utils'], |
| 86 | + # } |
| 87 | + package { "${python::version}-scldev": |
| 88 | + ensure => $dev_ensure, |
| 89 | + require => Package['scl-utils'], |
| 90 | + } |
| 91 | + # This looks absurd but I can't figure out a better way |
| 92 | + $pip_exec_onlyif = $pip_ensure ? { |
| 93 | + present => '/bin/true', |
| 94 | + default => '/bin/false', |
| 95 | + } |
| 96 | + exec { 'python-scl-pip-install': |
| 97 | + require => Package['scl-utils'], |
| 98 | + command => "scl enable ${python::version} -- easy_install pip", |
| 99 | + path => ['/usr/bin', '/bin'], |
| 100 | + onlyif => $pip_exec_onlyif, |
| 101 | + creates => "/opt/rh/${python::version}/root/usr/bin/pip", |
| 102 | + } |
| 103 | + } |
58 | 104 | default: { |
59 | 105 | if $::osfamily == 'RedHat' { |
60 | 106 | if $pip_ensure == present { |
61 | | - include 'epel' |
62 | | - Class['epel'] -> Package[$pip] |
| 107 | + if $python::use_epel == true { |
| 108 | + include 'epel' |
| 109 | + Class['epel'] -> Package[$pip] |
| 110 | + } |
63 | 111 | } |
64 | 112 | if ($venv_ensure == present) and ($::operatingsystemrelease =~ /^6/) { |
65 | | - include 'epel' |
66 | | - Class['epel'] -> Package['python-virtualenv'] |
| 113 | + if $python::use_epel == true { |
| 114 | + include 'epel' |
| 115 | + Class['epel'] -> Package[$python_virtualenv] |
| 116 | + } |
67 | 117 | } |
68 | 118 | } |
69 | | - package { 'python-virtualenv': ensure => $venv_ensure } |
| 119 | + package { $python_virtualenv: ensure => $venv_ensure } |
70 | 120 | package { $pip: ensure => $pip_ensure } |
71 | 121 | package { $pythondev: ensure => $dev_ensure } |
72 | 122 | package { $python: ensure => present } |
|
80 | 130 | } |
81 | 131 | package { 'gunicorn': ensure => $gunicorn_ensure } |
82 | 132 | } |
83 | | - |
84 | 133 | } |
0 commit comments