diff --git a/manifests/init.pp b/manifests/init.pp index a62975b5..8b5ae4b6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -64,7 +64,7 @@ } unless $version =~ Pattern[/\A(python)?[0-9](\.[0-9])+/, - /\Apypy\Z/, /\Asystem\Z/] { + /\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] { fail("version needs to be pypy, system or a version string like '3.5' or 'python3.5)") } diff --git a/manifests/install.pp b/manifests/install.pp index 22ae9e4a..63c88079 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -8,10 +8,11 @@ $python_version = getparam(Class['python'], 'version') $python = $python_version ? { - 'system' => 'python', - 'pypy' => 'pypy', + 'system' => 'python', + 'pypy' => 'pypy', /\A(python)?([0-9](\.?[0-9])+)/ => "python${2}", - default => "python${python::version}", + /\Arh-python[0-9]{2}/ => $python_version, + default => "python${python::version}", } $pythondev = $facts['os']['family'] ? { diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 579f7b11..59b582ed 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -59,7 +59,7 @@ } # pyvenv is deprecated since 3.6 and will be removed in 3.8 - if (versioncmp($facts['python3_version'], '3.6') >=0) { + if (versioncmp($normalized_python_version, '3.6') >=0) { $virtualenv_cmd = "${python::exec_prefix}python${normalized_python_version} -m venv" } else { $virtualenv_cmd = "${python::exec_prefix}pyvenv-${normalized_python_version}" diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index ab5b549d..208462ca 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -129,7 +129,7 @@ end end end - when 'RedHat' + when 'RedHat', 'CentOS' case facts[:os]['release']['major'] when '5' # written for RHEL 5 @@ -204,23 +204,6 @@ } 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: '' } } @@ -262,12 +245,75 @@ context 'on a Redhat 6 OS' do it { is_expected.to contain_class('python::install') } it { is_expected.to contain_package('pip').with_name('python-pip') } + + describe 'with python::provider' do + context 'scl' do + describe 'with version' do + context '3.6 SCL meta package' do + let(:params) { { version: 'rh-python36' } } + + it { is_expected.to compile.with_all_deps } + end + context '3.6 SCL python package' do + let(:params) { { version: 'rh-python36-python' } } + + it { is_expected.to compile.with_all_deps } + end + end + 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 + end end + when '7' context 'on a Redhat 7 OS' do it { is_expected.to contain_class('python::install') } it { is_expected.to contain_package('pip').with_name('python2-pip') } + + describe 'with python::provider' do + context 'scl' do + describe 'with version' do + context '3.6 SCL meta package' do + let(:params) { { version: 'rh-python36' } } + + it { is_expected.to compile.with_all_deps } + end + context '3.6 SCL python package' do + let(:params) { { version: 'rh-python36-python' } } + + it { is_expected.to compile.with_all_deps } + end + end + 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 + end end end end