From 56661bc43eb776d8fa7d4bed07b8132b4500d3d0 Mon Sep 17 00:00:00 2001 From: ju5t Date: Mon, 12 Dec 2016 23:16:44 +0100 Subject: [PATCH] Fix pip package name on EL7 (#347) Now uses the correct package name 'python2-pip'. Due to a recent change in EPEL the python-pip package was renamed to python2-pip. This currently breaks this module on CentOS 7. This commit makes sure that it defaults to python2-pip if the system is running Python 2 on CentOS 7 when using EPEL. * Remove the unneeded dependency on EPEL * Added pip package tests on RHEL 5 and 6 --- manifests/install.pp | 3 +++ spec/classes/python_spec.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index 6d3cb7e3..972d646f 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -213,6 +213,9 @@ if $::python::version =~ /^3/ { $pip_category = undef $pip_package = 'python3-pip' + } elsif ($::osfamily == 'RedHat') and (versioncmp($::operatingsystemmajrelease, '7') >= 0) { + $pip_category = undef + $pip_package = 'python2-pip' } elsif $::osfamily == 'Gentoo' { $pip_category = 'dev-python' $pip_package = 'pip' diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index 9448fa6c..727447c6 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -138,6 +138,7 @@ it { is_expected.to contain_package("python") } it { is_expected.to contain_package("python-dev").with_name("python-devel") } it { is_expected.to contain_package("pip") } + it { is_expected.to contain_package("pip").with_name('python-pip') } # Basic python packages (from pip) it { is_expected.to contain_package("virtualenv")} @@ -217,6 +218,38 @@ end end + context "on a Redhat 6 OS" do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemmajrelease => '6', + :concat_basedir => '/dne', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { is_expected.to contain_class("python::install") } + it { is_expected.to contain_package("pip").with_name('python-pip') } + end + + context "on a Redhat 7 OS" do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemmajrelease => '7', + :concat_basedir => '/dne', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { is_expected.to contain_class("python::install") } + it { is_expected.to contain_package("pip").with_name('python2-pip') } + end + context "on a SLES 11 SP3" do let :facts do {