Skip to content

Commit 8b7c1e9

Browse files
authored
Merge pull request #464 from aspectcapital/issue-463
Add manage_scl boolean to control managing SCL
2 parents af0cfe1 + caad10b commit 8b7c1e9

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

manifests/init.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# @param manage_gunicorn Allow Installation / Removal of Gunicorn.
1717
# @param provider What provider to use for installation of the packages, except gunicorn and Python itself.
1818
# @param use_epel to determine if the epel class is used.
19+
# @param manage_scl Whether to manage core SCL packages or not.
1920
#
2021
# @example install python from system python
2122
# class { 'python':
@@ -25,7 +26,7 @@
2526
# virtualenv => 'present',
2627
# gunicorn => 'present',
2728
# }
28-
# @example install python3 from scl report
29+
# @example install python3 from scl repo
2930
# class { 'python' :
3031
# ensure => 'present',
3132
# version => 'rh-python36-python',
@@ -53,6 +54,7 @@
5354
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
5455
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
5556
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
57+
Boolean $manage_scl = $python::params::manage_scl,
5658
) inherits python::params {
5759

5860
$exec_prefix = $provider ? {

manifests/install.pp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,26 @@
9393
# SCL is only valid in the RedHat family. If RHEL, package must be
9494
# enabled using the subscription manager outside of puppet. If CentOS,
9595
# the centos-release-SCL will install the repository.
96-
$install_scl_repo_package = $::operatingsystem ? {
97-
'CentOS' => 'present',
98-
default => 'absent',
99-
}
96+
if $python::manage_scl {
97+
$install_scl_repo_package = $facts['os']['name'] ? {
98+
'CentOS' => 'present',
99+
default => 'absent',
100+
}
100101

101-
package { 'centos-release-scl':
102-
ensure => $install_scl_repo_package,
103-
before => Package['scl-utils'],
104-
}
105-
package { 'scl-utils':
106-
ensure => 'latest',
107-
before => Package['python'],
102+
package { 'centos-release-scl':
103+
ensure => $install_scl_repo_package,
104+
before => Package['scl-utils'],
105+
}
106+
package { 'scl-utils':
107+
ensure => 'present',
108+
before => Package['python'],
109+
}
110+
111+
Package['scl-utils'] -> Package["${python}-scldevel"]
112+
113+
if $pip_ensure != 'absent' {
114+
Package['scl-utils'] -> Exec['python-scl-pip-install']
115+
}
108116
}
109117

110118
# This gets installed as a dependency anyway
@@ -113,15 +121,13 @@
113121
# require => Package['scl-utils'],
114122
# }
115123
package { "${python}-scldevel":
116-
ensure => $dev_ensure,
117-
require => Package['scl-utils'],
124+
ensure => $dev_ensure,
118125
}
119126
if $pip_ensure != 'absent' {
120127
exec { 'python-scl-pip-install':
121128
command => "${python::exec_prefix}easy_install pip",
122129
path => ['/usr/bin', '/bin'],
123130
creates => "/opt/rh/${python::version}/root/usr/bin/pip",
124-
require => Package['scl-utils'],
125131
}
126132
}
127133
}

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
$manage_gunicorn = true
1414
$provider = undef
1515
$valid_versions = undef
16+
$manage_scl = true
1617

1718
if $::osfamily == 'RedHat' {
1819
if $::operatingsystem != 'Fedora' {

spec/classes/python_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,23 @@
204204
}
205205
end
206206

207+
context 'scl' do
208+
describe 'with manage_scl' do
209+
context 'true' do
210+
let(:params) { { provider: 'scl', manage_scl: true } }
211+
212+
it { is_expected.to contain_package('centos-release-scl') }
213+
it { is_expected.to contain_package('scl-utils') }
214+
end
215+
context 'false' do
216+
let(:params) { { provider: 'scl', manage_scl: false } }
217+
218+
it { is_expected.not_to contain_package('centos-release-scl') }
219+
it { is_expected.not_to contain_package('scl-utils') }
220+
end
221+
end
222+
end
223+
207224
# python::provider
208225
context 'default' do
209226
let(:params) { { provider: '' } }

0 commit comments

Comments
 (0)