From caad10ba0ed4e00e6efc3b274ea23c46d60bcdd6 Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Fri, 22 Feb 2019 12:14:56 +0000 Subject: [PATCH] Add manage_scl boolean to control managing SCL --- manifests/init.pp | 4 +++- manifests/install.pp | 34 ++++++++++++++++++++-------------- manifests/params.pp | 1 + spec/classes/python_spec.rb | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e267ce16..a62975b5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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': @@ -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', @@ -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 ? { diff --git a/manifests/install.pp b/manifests/install.pp index b6911259..50990f01 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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 @@ -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'], } } } diff --git a/manifests/params.pp b/manifests/params.pp index d7bfdaa2..6aa9f996 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,6 +13,7 @@ $manage_gunicorn = true $provider = undef $valid_versions = undef + $manage_scl = true if $::osfamily == 'RedHat' { if $::operatingsystem != 'Fedora' { diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index d5ee2771..547feb29 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -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: '' } }