From 5bd8f1be290ee9eb2fa2f1b094dfabce28edf3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Fri, 15 Sep 2023 08:53:16 -1000 Subject: [PATCH] Allow to skip management of python dev package Just like we can skip managing the pip and venv packages, allow to opt-out of managing the dev package. Enforcing a state of these packages sometimes cause trouble if the user of the module does not care about them but they get installed as another package dependency (e.g. syslog-ng-mod-python depends on python-venv, by default python-venv is ensured absent, so on each run Puppet wants to install syslog-ng-mod-python (which install python-venv as a dependency) or remove python-venv (which remove syslog-ng-mod-python as a dependency)). This can be avoided using the corresponding `manage_XXX_package` paramater, but `manage_dev_package` was missing. --- REFERENCE.md | 9 +++++++++ manifests/init.pp | 2 ++ manifests/install.pp | 6 +++--- spec/classes/python_spec.rb | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 2aac08b3..424472ea 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -79,6 +79,7 @@ The following parameters are available in the `python` class: * [`umask`](#-python--umask) * [`manage_gunicorn`](#-python--manage_gunicorn) * [`manage_python_package`](#-python--manage_python_package) +* [`manage_dev_package`](#-python--manage_dev_package) * [`manage_venv_package`](#-python--manage_venv_package) * [`manage_pip_package`](#-python--manage_pip_package) * [`venv`](#-python--venv) @@ -192,6 +193,14 @@ manage the state for package python Default value: `true` +##### `manage_dev_package` + +Data type: `Boolean` + +manage the state of the python development package + +Default value: `true` + ##### `manage_venv_package` Data type: `Boolean` diff --git a/manifests/init.pp b/manifests/init.pp index 5b3c9fdf..b457edbd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,6 +19,7 @@ # @param umask The default umask for invoked exec calls. # @param manage_gunicorn manage the state for package gunicorn # @param manage_python_package manage the state for package python +# @param manage_dev_package manage the state of the python development package # @param manage_venv_package manage the state for package venv # @param manage_pip_package manage the state for package pip # @@ -45,6 +46,7 @@ Python::Package::Ensure $gunicorn = 'absent', Boolean $manage_gunicorn = true, Boolean $manage_python_package = true, + Boolean $manage_dev_package = true, Boolean $manage_venv_package = $python::params::manage_venv_package, Boolean $manage_pip_package = $python::params::manage_pip_package, String[1] $gunicorn_package_name = $python::params::gunicorn_package_name, diff --git a/manifests/install.pp b/manifests/install.pp index 6a738435..5d25efda 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -53,7 +53,7 @@ } } - if $pythondev { + if $python::manage_dev_package and $pythondev { package { 'python-dev': ensure => $python::dev, name => $pythondev, @@ -179,7 +179,7 @@ } } - if $pythondev { + if $python::manage_dev_package and $pythondev { package { 'python-dev': ensure => $python::dev, name => $pythondev, @@ -196,7 +196,7 @@ } } - if $pythondev { + if $python::manage_dev_package and $pythondev { package { 'python-dev': ensure => $python::dev, name => $pythondev, diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index cca3ef65..d3bde4a4 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -34,6 +34,7 @@ let :params do { manage_python_package: false, + manage_dev_package: false, manage_pip_package: false, manage_venv_package: false } @@ -41,6 +42,7 @@ 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_package('python-venv') } end