Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental support for SCL repositories on RHEL and CentOS #214

Merged
merged 9 commits into from
Jul 21, 2015
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ python::python_pips:
virtualenv: "/opt/env2"
```

### Using SCL packages from RedHat or CentOS

To use this module with the Red Hat Software Collections (SCL) or the CentOS
equivalents, set python::provider to 'scl' and python::version to the name of
the collection you want to use (e.g., 'python27', 'python33', or
'rh-python34').


## Authors

[Sergey Stankevich](https://github.com/stankevich) | [Shiva Poudel](https://github.com/shivapoudel) | [Garrett Honeycutt](http://learnpuppet.com)
5 changes: 3 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@

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

if $provider == 'pip' {
validate_re($version, ['^(2\.[4-7]\.\d|3\.\d\.\d)$','^system$'])
# this will only be checked if not pip, every other string would be rejected by provider check
} elsif $provider == 'scl' {
validate_re($version, concat(['python33', 'python27', 'rh-python34'], $valid_versions))
} else {
validate_re($version, concat(['system', 'pypy'], $valid_versions))
}
Expand Down
40 changes: 40 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,46 @@
package { 'pip': ensure => latest, provider => pip }
package { "python==${python::version}": ensure => latest, provider => pip }
}
scl: {
# SCL is only valid in the RedHat family. If RHEL, package must be
# enabled using the subscription manager outside of puppet. If CentOS,
# the centos-release-SCL will install the repository.
$install_scl_repo_package = $::operatingsystem ? {
'CentOS' => present,
default => absent,
}

package { 'centos-release-SCL':
ensure => $install_scl_repo_package,
before => Package['scl-utils'],
}
package { 'scl-utils': ensure => latest, }
package { $::python::version:
ensure => present,
require => Package['scl-utils'],
}
# This gets installed as a dependency anyway
# package { "${python::version}-python-virtualenv":
# ensure => $venv_ensure,
# require => Package['scl-utils'],
# }
package { "${python::version}-scldev":
ensure => $dev_ensure,
require => Package['scl-utils'],
}
# This looks absurd but I can't figure out a better way
$pip_exec_onlyif = $pip_ensure ? {
present => '/bin/true',
default => '/bin/false',
}
exec { 'python-scl-pip-install':
require => Package['scl-utils'],
command => "scl enable ${python::version} -- easy_install pip",
path => ['/usr/bin', '/bin'],
onlyif => $pip_exec_onlyif,
creates => "/opt/rh/${python::version}/root/usr/bin/pip",
}
}
default: {
if $::osfamily == 'RedHat' {
if $pip_ensure == present {
Expand Down
9 changes: 6 additions & 3 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@

if $ensure == 'present' {

$virtualenv_cmd = $version ? {
'system' => 'pyvenv',
default => "pyvenv-${version}",
$virtualenv_cmd = $python::provider ? {
'scl' => "scl enable ${python::version} -- pyvenv --clear",
default => $version ? {
'system' => 'pyvenv',
default => "pyvenv-${version}",
}
}

if ( $systempkgs == true ) {
Expand Down