From b08bf1a94ccb6080ca5cc18b21c5d30bb0eb2c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Fri, 15 Sep 2023 10:11:04 -1000 Subject: [PATCH] Install dev packages in python::install::dev --- REFERENCE.md | 5 +++++ manifests/install.pp | 18 +++------------ manifests/install/dev.pp | 38 ++++++++++++++++++++++++++++++++ spec/classes/install/dev_spec.rb | 29 ++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 manifests/install/dev.pp create mode 100644 spec/classes/install/dev_spec.rb diff --git a/REFERENCE.md b/REFERENCE.md index 3c51151b..d46ccdc0 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -9,6 +9,7 @@ #### Public Classes * [`python`](#python): Installs and manages python, python-dev and gunicorn. +* [`python::install::dev`](#python--install--dev): Installs python development packages * [`python::pip::bootstrap`](#python--pip--bootstrap): allow to bootstrap pip when python is managed from other module #### Private Classes @@ -289,6 +290,10 @@ Data type: `Stdlib::Absolutepath` Default value: `'/opt/python'` +### `python::install::dev` + +Installs python development packages + ### `python::pip::bootstrap` allow to bootstrap pip when python is managed from other module diff --git a/manifests/install.pp b/manifests/install.pp index c3db3d80..d07465d0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -54,10 +54,7 @@ } if $python::manage_dev_package and $pythondev { - package { 'python-dev': - ensure => $python::dev, - name => $pythondev, - } + contain python::install::dev } # Respect the $python::pip setting @@ -180,12 +177,7 @@ } if $python::manage_dev_package and $pythondev { - package { 'python-dev': - ensure => $python::dev, - name => $pythondev, - alias => $pythondev, - provider => 'yum', - } + contain python::install::dev } } default: { @@ -197,11 +189,7 @@ } if $python::manage_dev_package and $pythondev { - package { 'python-dev': - ensure => $python::dev, - name => $pythondev, - alias => $pythondev, - } + contain python::install::dev } } } diff --git a/manifests/install/dev.pp b/manifests/install/dev.pp new file mode 100644 index 00000000..a8a5103d --- /dev/null +++ b/manifests/install/dev.pp @@ -0,0 +1,38 @@ +# @summary Installs python development packages +class python::install::dev { + include python + + case $python::provider { + 'pip': { + package { 'python-dev': + ensure => $python::dev, + name => $python::install::pythondev, + } + } + 'scl': { + } + 'rhscl': { + } + 'anaconda': { + } + default: { + case $facts['os']['family'] { + 'AIX': { + package { 'python-dev': + ensure => $python::dev, + name => $python::install::pythondev, + alias => $python::install::pythondev, + provider => 'yum', + } + } + default: { + package { 'python-dev': + ensure => $python::dev, + name => $python::install::pythondev, + alias => $python::install::pythondev, + } + } + } + } + } +} diff --git a/spec/classes/install/dev_spec.rb b/spec/classes/install/dev_spec.rb new file mode 100644 index 00000000..d1a662b0 --- /dev/null +++ b/spec/classes/install/dev_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'python::install::dev' 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('python-dev').with(ensure: 'absent') } + end + + context 'when ensuring dev is setup' do + let(:pre_condition) do + <<~PP + class { 'python': + dev => present, + } + PP + end + + it { is_expected.to contain_package('python-dev').with(ensure: 'present') } + end + end + end +end