Skip to content

Commit 03d0e99

Browse files
author
Shiva Poudel
committed
Merge pull request voxpupuli#214 from sorreltree/master
Experimental support for SCL repositories on RHEL and CentOS
2 parents aac288a + 409ff8a commit 03d0e99

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@ python::python_pips:
278278
virtualenv: "/opt/env2"
279279
```
280280
281+
### Using SCL packages from RedHat or CentOS
282+
283+
To use this module with the Red Hat Software Collections (SCL) or the CentOS
284+
equivalents, set python::provider to 'scl' and python::version to the name of
285+
the collection you want to use (e.g., 'python27', 'python33', or
286+
'rh-python34').
287+
288+
281289
## Authors
282290
283291
[Sergey Stankevich](https://github.com/stankevich) | [Shiva Poudel](https://github.com/shivapoudel) | [Garrett Honeycutt](http://learnpuppet.com)

manifests/init.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@
7272

7373
# validate inputs
7474
if $provider != undef {
75-
validate_re($provider, ['^pip$'], 'Only "pip" is a valid provider besides the system default.')
75+
validate_re($provider, ['^(pip|scl)$'], 'Only "pip" or "scl" are valid providers besides the system default.')
7676
}
7777

7878
if $provider == 'pip' {
7979
validate_re($version, ['^(2\.[4-7]\.\d|3\.\d\.\d)$','^system$'])
80-
# this will only be checked if not pip, every other string would be rejected by provider check
80+
} elsif $provider == 'scl' {
81+
validate_re($version, concat(['python33', 'python27', 'rh-python34'], $valid_versions))
8182
} else {
8283
validate_re($version, concat(['system', 'pypy'], $valid_versions))
8384
}

manifests/install.pp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,46 @@
6161
package { 'pip': ensure => latest, provider => pip }
6262
package { "python==${python::version}": ensure => latest, provider => pip }
6363
}
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+
}
64104
default: {
65105
if $::osfamily == 'RedHat' {
66106
if $pip_ensure == present {

manifests/pyvenv.pp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@
6161

6262
if $ensure == 'present' {
6363

64-
$virtualenv_cmd = $version ? {
65-
'system' => 'pyvenv',
66-
default => "pyvenv-${version}",
64+
$virtualenv_cmd = $python::provider ? {
65+
'scl' => "scl enable ${python::version} -- pyvenv --clear",
66+
default => $version ? {
67+
'system' => 'pyvenv',
68+
default => "pyvenv-${version}",
69+
}
6770
}
6871

6972
if ( $systempkgs == true ) {

0 commit comments

Comments
 (0)