From b28f2121e5be7bd13cd217cd6744a941fb5749e9 Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Sat, 23 Oct 2021 12:59:29 -0400 Subject: [PATCH] (#236) Enable python module stream on EL8. Bump minimum puppet version The certbot package on EL8 currently requires `/usr/bin/python3.6`, which is part of the `python36` module stream, and needs enabled in order to install. Bump the minimum puppet version to 6.15.0 since the enable_only feature of the dnfmodule provider was added in https://tickets.puppetlabs.com/browse/PUP-10235 --- REFERENCE.md | 18 ++++++++++++++++++ manifests/init.pp | 2 ++ manifests/install.pp | 11 +++++++++++ metadata.json | 2 +- spec/classes/letsencrypt_install_spec.rb | 10 +++++++++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index bc62d95e..6e3690fc 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -64,6 +64,7 @@ The following parameters are available in the `letsencrypt` class: * [`environment`](#environment) * [`package_name`](#package_name) * [`package_ensure`](#package_ensure) +* [`dnfmodule_version`](#dnfmodule_version) * [`package_command`](#package_command) * [`config_file`](#config_file) * [`config`](#config) @@ -119,6 +120,14 @@ The value passed to `ensure` when installing the client package. Default value: `'installed'` +##### `dnfmodule_version` + +Data type: `String` + +The yum module stream version to enable on EL8 and greater variants using the `package` method with the `dnfmodule` provider. + +Default value: `'python36'` + ##### `package_command` Data type: `String` @@ -305,6 +314,7 @@ The following parameters are available in the `letsencrypt::install` class: * [`configure_epel`](#configure_epel) * [`package_ensure`](#package_ensure) * [`package_name`](#package_name) +* [`dnfmodule_version`](#dnfmodule_version) ##### `configure_epel` @@ -330,6 +340,14 @@ Name of package to use when installing the client package. Default value: `$letsencrypt::package_name` +##### `dnfmodule_version` + +Data type: `String` + +The yum module stream version to enable on EL8 and greater variants using the `package` method with the `dnfmodule` provider. + +Default value: `$letsencrypt::dnfmodule_version` + ### `letsencrypt::plugin::dns_cloudflare` This class installs and configures the Let's Encrypt dns-cloudflare plugin. diff --git a/manifests/init.pp b/manifests/init.pp index 5c90de9a..41f6b316 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,6 +16,7 @@ # @param environment An optional array of environment variables # @param package_name Name of package and command to use when installing the client package. # @param package_ensure The value passed to `ensure` when installing the client package. +# @param dnfmodule_version The yum module stream version to enable on EL8 and greater variants using the `package` method with the `dnfmodule` provider. # @param package_command Path or name for letsencrypt executable. # @param config_file The path to the configuration file for the letsencrypt cli. # @param config A hash representation of the letsencrypt configuration file. @@ -57,6 +58,7 @@ Array $environment = [], String $package_name = 'certbot', $package_ensure = 'installed', + String[1] $dnfmodule_version = 'python36', String $package_command = 'certbot', Stdlib::Unixpath $config_dir = '/etc/letsencrypt', String $config_file = "${config_dir}/cli.ini", diff --git a/manifests/install.pp b/manifests/install.pp index af1b47c3..c50c4da0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -3,12 +3,23 @@ # @param configure_epel A feature flag to include the 'epel' class and depend on it for package installation. # @param package_ensure The value passed to `ensure` when installing the client package. # @param package_name Name of package to use when installing the client package. +# @param dnfmodule_version The yum module stream version to enable on EL8 and greater variants using the `package` method with the `dnfmodule` provider. # class letsencrypt::install ( Boolean $configure_epel = $letsencrypt::configure_epel, String $package_name = $letsencrypt::package_name, String $package_ensure = $letsencrypt::package_ensure, + String[1] $dnfmodule_version = $letsencrypt::dnfmodule_version, ) { + if ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] >= '8') { + package { 'enable python module stream': + name => $dnfmodule_version, + enable_only => true, + provider => 'dnfmodule', + before => Package['letsencrypt'], + } + } + package { 'letsencrypt': ensure => $package_ensure, name => $package_name, diff --git a/metadata.json b/metadata.json index 7df8af0a..571eca6c 100644 --- a/metadata.json +++ b/metadata.json @@ -70,7 +70,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.1.0 < 8.0.0" + "version_requirement": ">= 6.15.0 < 8.0.0" } ], "dependencies": [ diff --git a/spec/classes/letsencrypt_install_spec.rb b/spec/classes/letsencrypt_install_spec.rb index 3a39dd90..418f826f 100644 --- a/spec/classes/letsencrypt_install_spec.rb +++ b/spec/classes/letsencrypt_install_spec.rb @@ -9,7 +9,8 @@ { configure_epel: false, package_ensure: 'installed', - package_name: 'letsencrypt' + package_name: 'letsencrypt', + dnfmodule_version: 'python36' } end let(:additional_params) { {} } @@ -44,6 +45,13 @@ is_expected.to contain_package('letsencrypt').that_requires('Class[epel]') end end + + case facts[:operatingsystemmajrelease] + when '7' + it { is_expected.not_to contain_package('enable python module stream').with_name('python36') } + when '8' + it { is_expected.to contain_package('enable python module stream').with_name('python36').with_enable_only('true').with_provider('dnfmodule') } + end end end end