Skip to content

Commit

Permalink
Merge pull request #464 from aspectcapital/issue-463
Browse files Browse the repository at this point in the history
Add manage_scl boolean to control managing SCL
  • Loading branch information
bastelfreak authored Feb 27, 2019
2 parents af0cfe1 + caad10b commit 8b7c1e9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# @param manage_gunicorn Allow Installation / Removal of Gunicorn.
# @param provider What provider to use for installation of the packages, except gunicorn and Python itself.
# @param use_epel to determine if the epel class is used.
# @param manage_scl Whether to manage core SCL packages or not.
#
# @example install python from system python
# class { 'python':
Expand All @@ -25,7 +26,7 @@
# virtualenv => 'present',
# gunicorn => 'present',
# }
# @example install python3 from scl report
# @example install python3 from scl repo
# class { 'python' :
# ensure => 'present',
# version => 'rh-python36-python',
Expand Down Expand Up @@ -53,6 +54,7 @@
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
Boolean $manage_scl = $python::params::manage_scl,
) inherits python::params {

$exec_prefix = $provider ? {
Expand Down
34 changes: 20 additions & 14 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,26 @@
# 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',
}
if $python::manage_scl {
$install_scl_repo_package = $facts['os']['name'] ? {
'CentOS' => 'present',
default => 'absent',
}

package { 'centos-release-scl':
ensure => $install_scl_repo_package,
before => Package['scl-utils'],
}
package { 'scl-utils':
ensure => 'latest',
before => Package['python'],
package { 'centos-release-scl':
ensure => $install_scl_repo_package,
before => Package['scl-utils'],
}
package { 'scl-utils':
ensure => 'present',
before => Package['python'],
}

Package['scl-utils'] -> Package["${python}-scldevel"]

if $pip_ensure != 'absent' {
Package['scl-utils'] -> Exec['python-scl-pip-install']
}
}

# This gets installed as a dependency anyway
Expand All @@ -113,15 +121,13 @@
# require => Package['scl-utils'],
# }
package { "${python}-scldevel":
ensure => $dev_ensure,
require => Package['scl-utils'],
ensure => $dev_ensure,
}
if $pip_ensure != 'absent' {
exec { 'python-scl-pip-install':
command => "${python::exec_prefix}easy_install pip",
path => ['/usr/bin', '/bin'],
creates => "/opt/rh/${python::version}/root/usr/bin/pip",
require => Package['scl-utils'],
}
}
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$manage_gunicorn = true
$provider = undef
$valid_versions = undef
$manage_scl = true

if $::osfamily == 'RedHat' {
if $::operatingsystem != 'Fedora' {
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@
}
end

context 'scl' do
describe 'with manage_scl' do
context 'true' do
let(:params) { { provider: 'scl', manage_scl: true } }

it { is_expected.to contain_package('centos-release-scl') }
it { is_expected.to contain_package('scl-utils') }
end
context 'false' do
let(:params) { { provider: 'scl', manage_scl: false } }

it { is_expected.not_to contain_package('centos-release-scl') }
it { is_expected.not_to contain_package('scl-utils') }
end
end
end

# python::provider
context 'default' do
let(:params) { { provider: '' } }
Expand Down

0 comments on commit 8b7c1e9

Please sign in to comment.