|
27 | 27 | 'Suse' => "${python}-devel", |
28 | 28 | } |
29 | 29 |
|
30 | | - $python_virtualenv = $::lsbdistcodename ? { |
31 | | - 'jessie' => 'virtualenv', |
32 | | - default => 'python-virtualenv', |
33 | | - } |
34 | | - |
35 | | - # pip version: use only for installation via os package manager! |
36 | | - if $::python::version =~ /^3/ { |
37 | | - $pip = 'python3-pip' |
38 | | - } else { |
39 | | - $pip = 'python-pip' |
40 | | - } |
41 | | - |
42 | 30 | $dev_ensure = $python::dev ? { |
43 | 31 | true => present, |
44 | | - default => absent, |
| 32 | + false => absent, |
| 33 | + default => $python::dev, |
45 | 34 | } |
46 | 35 |
|
47 | 36 | $pip_ensure = $python::pip ? { |
48 | 37 | true => present, |
49 | | - default => absent, |
| 38 | + false => absent, |
| 39 | + default => $python::pip, |
50 | 40 | } |
51 | 41 |
|
52 | 42 | $venv_ensure = $python::virtualenv ? { |
53 | 43 | true => present, |
54 | | - default => absent, |
| 44 | + false => absent, |
| 45 | + default => $python::virtualenv, |
| 46 | + } |
| 47 | + |
| 48 | + package { 'python': |
| 49 | + ensure => $python::ensure, |
| 50 | + name => $python, |
| 51 | + } |
| 52 | + |
| 53 | + package { 'python-dev': |
| 54 | + ensure => $dev_ensure, |
| 55 | + name => $pythondev, |
| 56 | + } |
| 57 | + |
| 58 | + package { 'pip': |
| 59 | + ensure => $pip_ensure, |
| 60 | + } |
| 61 | + |
| 62 | + package { 'virtualenv': |
| 63 | + ensure => $venv_ensure, |
55 | 64 | } |
56 | 65 |
|
57 | | - # Install latest from pip if pip is the provider |
58 | 66 | case $python::provider { |
59 | 67 | pip: { |
60 | | - package { 'virtualenv': ensure => latest, provider => pip } |
61 | | - package { 'pip': ensure => latest, provider => pip } |
62 | | - package { "python==${python::version}": ensure => latest, provider => pip } |
| 68 | + Package <| title == 'pip' |> { |
| 69 | + name => 'pip', |
| 70 | + provider => 'pip', |
| 71 | + } |
| 72 | + Package <| title == 'virtualenv' |> { |
| 73 | + provider => 'pip', |
| 74 | + } |
63 | 75 | } |
64 | 76 | scl: { |
65 | 77 | # SCL is only valid in the RedHat family. If RHEL, package must be |
66 | 78 | # enabled using the subscription manager outside of puppet. If CentOS, |
67 | 79 | # the centos-release-SCL will install the repository. |
68 | 80 | $install_scl_repo_package = $::operatingsystem ? { |
69 | | - 'CentOS' => present, |
70 | | - default => absent, |
| 81 | + 'CentOS' => present, |
| 82 | + default => absent, |
71 | 83 | } |
72 | 84 |
|
73 | 85 | package { 'centos-release-SCL': |
74 | 86 | ensure => $install_scl_repo_package, |
75 | 87 | before => Package['scl-utils'], |
76 | 88 | } |
77 | | - package { 'scl-utils': ensure => latest, } |
78 | | - package { $::python::version: |
79 | | - ensure => present, |
80 | | - require => Package['scl-utils'], |
| 89 | + package { 'scl-utils': |
| 90 | + ensure => latest, |
| 91 | + before => Package['python'], |
81 | 92 | } |
| 93 | + |
82 | 94 | # This gets installed as a dependency anyway |
83 | 95 | # package { "${python::version}-python-virtualenv": |
84 | 96 | # ensure => $venv_ensure, |
|
106 | 118 | tag => 'python-scl-repo', |
107 | 119 | } |
108 | 120 |
|
109 | | - package { $::python::version: |
110 | | - ensure => present, |
111 | | - tag => 'python-scl-package', |
| 121 | + Package <| title == 'python' |> { |
| 122 | + tag => 'python-scl-package', |
112 | 123 | } |
113 | 124 |
|
114 | 125 | package { "${python::version}-scldev": |
115 | 126 | ensure => $dev_ensure, |
116 | 127 | tag => 'python-scl-package', |
117 | 128 | } |
118 | 129 |
|
119 | | - if $pip_ensure { |
| 130 | + if $pip_ensure { |
120 | 131 | exec { 'python-scl-pip-install': |
121 | 132 | command => "${python::exec_prefix}easy_install pip", |
122 | 133 | path => ['/usr/bin', '/bin'], |
123 | 134 | creates => "/opt/rh/${python::version}/root/usr/bin/pip", |
124 | 135 | } |
125 | 136 | } |
| 137 | + |
126 | 138 | Package <| tag == 'python-scl-repo' |> -> |
127 | 139 | Package <| tag == 'python-scl-package' |> -> |
128 | 140 | Exec['python-scl-pip-install'] |
129 | 141 | } |
| 142 | + |
130 | 143 | default: { |
131 | 144 | if $::osfamily == 'RedHat' { |
132 | 145 | if $pip_ensure == present { |
133 | 146 | if $python::use_epel == true { |
134 | 147 | include 'epel' |
135 | | - Class['epel'] -> Package[$pip] |
| 148 | + Class['epel'] -> Package['pip'] |
136 | 149 | } |
137 | 150 | } |
138 | 151 | if ($venv_ensure == present) and ($::operatingsystemrelease =~ /^6/) { |
139 | 152 | if $python::use_epel == true { |
140 | 153 | include 'epel' |
141 | | - Class['epel'] -> Package[$python_virtualenv] |
| 154 | + Class['epel'] -> Package['virtualenv'] |
142 | 155 | } |
143 | 156 | } |
144 | 157 | } |
145 | | - package { $python_virtualenv: ensure => $venv_ensure } |
146 | | - package { $pip: ensure => $pip_ensure } |
147 | | - package { $pythondev: ensure => $dev_ensure } |
148 | | - package { $python: ensure => present } |
| 158 | + |
| 159 | + if $::python::version =~ /^3/ { |
| 160 | + $pip_package = 'python3-pip' |
| 161 | + } else { |
| 162 | + $pip_package = 'python-pip' |
| 163 | + } |
| 164 | + |
| 165 | + $virtualenv_package = $::lsbdistcodename ? { |
| 166 | + 'jessie' => 'virtualenv', |
| 167 | + default => 'python-virtualenv', |
| 168 | + } |
| 169 | + |
| 170 | + Package <| title == 'pip' |> { |
| 171 | + name => $pip_package, |
| 172 | + } |
| 173 | + |
| 174 | + Package <| title == 'virtualenv' |> { |
| 175 | + name => $virtualenv_package, |
| 176 | + } |
149 | 177 | } |
150 | 178 | } |
151 | 179 |
|
|
0 commit comments