diff --git a/REFERENCE.md b/REFERENCE.md
index 1dd7e63a..533d8d25 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -10,6 +10,7 @@
* [`python`](#python): Installs and manages python, python-dev and gunicorn.
* [`python::install::dev`](#python--install--dev): Installs python development packages
+* [`python::install::pip`](#python--install--pip): Installs python pip packages
* [`python::install::venv`](#python--install--venv): Installs python virtualenv packages
* [`python::pip::bootstrap`](#python--pip--bootstrap): allow to bootstrap pip when python is managed from other module
@@ -295,6 +296,10 @@ Default value: `'/opt/python'`
Installs python development packages
+### `python::install::pip`
+
+Installs python pip packages
+
### `python::install::venv`
Installs python virtualenv packages
diff --git a/manifests/install.pp b/manifests/install.pp
index 348aeda3..dff77609 100644
--- a/manifests/install.pp
+++ b/manifests/install.pp
@@ -38,10 +38,7 @@
case $python::provider {
'pip': {
if $python::manage_pip_package {
- package { 'pip':
- ensure => $python::pip,
- require => Package['python'],
- }
+ contain python::install::pip
}
if $python::manage_dev_package and $pythondev {
@@ -159,11 +156,7 @@
}
} else {
if $python::manage_pip_package {
- package { 'python-pip':
- ensure => $python::pip,
- require => Package['python'],
- provider => 'yum',
- }
+ contain python::install::pip
}
}
@@ -173,10 +166,7 @@
}
default: {
if $python::manage_pip_package {
- package { 'pip':
- ensure => $python::pip,
- require => Package['python'],
- }
+ contain python::install::pip
}
if $python::manage_dev_package and $pythondev {
diff --git a/manifests/install/pip.pp b/manifests/install/pip.pp
new file mode 100644
index 00000000..baf24c53
--- /dev/null
+++ b/manifests/install/pip.pp
@@ -0,0 +1,38 @@
+# @summary Installs python pip packages
+class python::install::pip {
+ include python
+
+ case $python::provider {
+ 'pip': {
+ package { 'pip':
+ ensure => $python::pip,
+ require => Package['python'],
+ }
+ }
+ 'scl': {
+ }
+ 'rhscl': {
+ }
+ 'anaconda': {
+ }
+ default: {
+ case $facts['os']['family'] {
+ 'AIX': {
+ unless String($python::version) =~ /^python3/ {
+ package { 'python-pip':
+ ensure => $python::pip,
+ require => Package['python'],
+ provider => 'yum',
+ }
+ }
+ }
+ default: {
+ package { 'pip':
+ ensure => $python::pip,
+ require => Package['python'],
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/spec/classes/install/pip_spec.rb b/spec/classes/install/pip_spec.rb
new file mode 100644
index 00000000..fc67d6c6
--- /dev/null
+++ b/spec/classes/install/pip_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'python::install::pip' do
+ on_supported_os.each do |os, facts|
+ context "on #{os}" do
+ let :facts do
+ facts
+ end
+
+ context 'with default settings' do
+ it { is_expected.to contain_package('pip').with(ensure: 'present') }
+ end
+
+ context 'when ensuring pip is absent' do
+ let(:pre_condition) do
+ <<~PP
+ class { 'python':
+ pip => absent,
+ }
+ PP
+ end
+
+ it { is_expected.to contain_package('pip').with(ensure: 'absent') }
+ end
+ end
+ end
+end
diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb
index f6fcf7d9..cdbc35f2 100644
--- a/spec/classes/python_spec.rb
+++ b/spec/classes/python_spec.rb
@@ -17,10 +17,10 @@
it { is_expected.to contain_class('python::config') }
it { is_expected.to contain_package('python') }
- if facts[:os]['family'] == 'Archlinux'
- it { is_expected.not_to contain_package('pip') }
+ if %w[Archlinux].include?(facts[:os]['family'])
+ it { is_expected.not_to contain_class('python::install::pip') }
else
- it { is_expected.to contain_package('pip') }
+ it { is_expected.to contain_class('python::install::pip') }
end
if %w[Archlinux FreeBSD RedHat].include?(facts[:os]['family'])
@@ -43,22 +43,10 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_package('python') }
it { is_expected.not_to contain_package('python-dev') }
- it { is_expected.not_to contain_package('pip') }
+ it { is_expected.not_to contain_class('python::install::pip') }
it { is_expected.not_to contain_class('python::install::venv') }
end
- context 'with packages present' do
- let :params do
- {
- manage_pip_package: true,
- pip: 'present',
- }
- end
-
- it { is_expected.to compile.with_all_deps }
- it { is_expected.to contain_package('pip').with(ensure: 'present') }
- end
-
case facts[:os]['family']
when 'Debian'
@@ -68,7 +56,7 @@
# Base debian packages.
it { is_expected.to contain_package('python') }
it { is_expected.to contain_package('python-dev') }
- it { is_expected.to contain_package('pip') }
+ it { is_expected.to contain_class('python::install::pip') }
describe 'with python::version' do
context 'python3.7' do