From b05fe374712eb3504fdab18e8cc5aab341bf7f75 Mon Sep 17 00:00:00 2001 From: Patrick Brideau Date: Thu, 13 Oct 2022 11:47:57 -0400 Subject: [PATCH 1/6] fix: support for different python version on rhel8 fix: linter --- manifests/apache/conf.pp | 12 ++++++++++++ manifests/apache/vhost.pp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/manifests/apache/conf.pp b/manifests/apache/conf.pp index 81802f4e..df6975bb 100644 --- a/manifests/apache/conf.pp +++ b/manifests/apache/conf.pp @@ -39,6 +39,18 @@ package_name => 'libapache2-mod-wsgi-py3', mod_path => '/usr/lib/apache2/modules/mod_wsgi.so', }, + 'RedHat' => $facts['os']['release']['major'] ? { + '8' => { + package_name => $puppetboard::python_version ? { + '3.6' => 'python3-mod_wsgi', + '3.8' => 'python38-mod_wsgi', + '3.9' => 'python39-mod_wsgi', + default => fail('python version not supported'), + }, + mod_path => 'modules/mod_wsgi_python3.so', + }, + default => {}, + }, default => {}, } class { 'apache::mod::wsgi': diff --git a/manifests/apache/vhost.pp b/manifests/apache/vhost.pp index 30672b06..e8d54002 100644 --- a/manifests/apache/vhost.pp +++ b/manifests/apache/vhost.pp @@ -51,6 +51,18 @@ package_name => 'libapache2-mod-wsgi-py3', mod_path => '/usr/lib/apache2/modules/mod_wsgi.so', }, + 'RedHat' => $facts['os']['release']['major'] ? { + '8' => { + package_name => $puppetboard::python_version ? { + '3.6' => 'python3-mod_wsgi', + '3.8' => 'python38-mod_wsgi', + '3.9' => 'python39-mod_wsgi', + default => fail('python version not supported'), + }, + mod_path => 'modules/mod_wsgi_python3.so', + }, + default => {}, + }, default => {}, } class { 'apache::mod::wsgi': From 85347acdb0b73b62a55b744b05c58eecd2f14e35 Mon Sep 17 00:00:00 2001 From: Patrick Brideau Date: Thu, 13 Oct 2022 11:48:33 -0400 Subject: [PATCH 2/6] test: different python version on rhel8 fix: linter --- metadata.json | 6 ++++++ spec/classes/apache/vhost_spec.rb | 36 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/metadata.json b/metadata.json index 7956a1ca..6b51888d 100644 --- a/metadata.json +++ b/metadata.json @@ -33,6 +33,12 @@ "18.04", "20.04" ] + }, + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "8" + ] } ], "requirements": [ diff --git a/spec/classes/apache/vhost_spec.rb b/spec/classes/apache/vhost_spec.rb index f2831896..4df06042 100644 --- a/spec/classes/apache/vhost_spec.rb +++ b/spec/classes/apache/vhost_spec.rb @@ -44,6 +44,42 @@ 'ensure' => 'file' ) end + + if ['RedHat'].include?(facts[:os]['family']) + ['3.6', '3.8', '3.9'].each do |python_version| + context "with python_versions #{python_version}" do + let(:pre_condition) do + [ + "class { 'puppetboard': python_version => \"#{python_version}\", }" + ] + end + + case python_version + when '3.6' + package_name = 'python3-mod_wsgi' + when '3.8' + package_name = 'python38-mod_wsgi' + when '3.9' + package_name = 'python39-mod_wsgi' + end + + it { is_expected.to contain_class('apache::mod::wsgi').with(package_name: package_name) } + end + end + + context 'with unsupported python_versions' do + let(:pre_condition) do + [ + "class { 'puppetboard': + python_version => '3.7', + } + " + ] + end + + it { is_expected.to raise_error(Puppet::Error, %r{python version not supported}) } + end + end end end end From f81c7adf87758c44e924932ea8ec092895a3090c Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Thu, 27 Oct 2022 17:00:32 +0100 Subject: [PATCH 3/6] try to make tests pass --- metadata.json | 6 ++++++ spec/acceptance/class_spec.rb | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/metadata.json b/metadata.json index 6b51888d..7fef34d1 100644 --- a/metadata.json +++ b/metadata.json @@ -39,6 +39,12 @@ "operatingsystemrelease": [ "8" ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "8" + ] } ], "requirements": [ diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 786a28ad..4d1ec2da 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -19,6 +19,7 @@ class { 'puppetdb': disable_ssl => true, manage_firewall => false, + database => 'embedded', } # Configure Puppetboard @@ -57,6 +58,7 @@ class { 'apache': class { 'puppetdb': disable_ssl => true, manage_firewall => false, + database => 'embedded', } # Configure Puppetboard @@ -106,6 +108,7 @@ class { 'puppetboard': class { 'puppetdb': disable_ssl => true, manage_firewall => false, + database => 'embedded', } EOS @@ -146,6 +149,7 @@ class { 'puppetboard::apache::conf': class { 'puppetdb': disable_ssl => true, manage_firewall => false, + database => 'embedded', } EOS @@ -194,6 +198,7 @@ class { 'puppetboard::apache::conf': class { 'puppetdb': disable_ssl => true, manage_firewall => false, + database => 'embedded', } EOS From 270dfe88c18371d4cf3ef6d84d07f0d2ba33318e Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Thu, 27 Oct 2022 17:14:36 +0100 Subject: [PATCH 4/6] try latests modules --- metadata.json | 2 +- spec/spec_helper_acceptance.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/metadata.json b/metadata.json index 7fef34d1..24160001 100644 --- a/metadata.json +++ b/metadata.json @@ -56,7 +56,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.5.0 < 9.0.0" }, { "name": "puppet/python", diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 478b496e..f6f24865 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -4,7 +4,7 @@ configure_beaker do |host| # Install additional modules for soft deps - install_module_from_forge_on(host, 'puppetlabs-apache', '>= 2.1.0 < 7.0.0') - install_module_from_forge_on(host, 'puppetlabs-puppetdb', '>= 7.6.0 < 8.0.0') - install_module_from_forge_on(host, 'puppet-epel', '>= 3.0.0 < 5.0.0') + install_module_from_forge_on(host, 'puppetlabs-apache', '>= 8.2.1 < 9.0.0') + install_module_from_forge_on(host, 'puppetlabs-puppetdb', '>= 7.10.0 < 8.0.0') + install_module_from_forge_on(host, 'puppet-epel', '>= 4.1.0 < 5.0.0') end From ea47939af3f0b3ff93831952c59dc20c77911eee Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Thu, 27 Oct 2022 17:23:59 +0100 Subject: [PATCH 5/6] Embedded is not supported with modern Puppetdb --- spec/acceptance/class_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 4d1ec2da..786a28ad 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -19,7 +19,6 @@ class { 'puppetdb': disable_ssl => true, manage_firewall => false, - database => 'embedded', } # Configure Puppetboard @@ -58,7 +57,6 @@ class { 'apache': class { 'puppetdb': disable_ssl => true, manage_firewall => false, - database => 'embedded', } # Configure Puppetboard @@ -108,7 +106,6 @@ class { 'puppetboard': class { 'puppetdb': disable_ssl => true, manage_firewall => false, - database => 'embedded', } EOS @@ -149,7 +146,6 @@ class { 'puppetboard::apache::conf': class { 'puppetdb': disable_ssl => true, manage_firewall => false, - database => 'embedded', } EOS @@ -198,7 +194,6 @@ class { 'puppetboard::apache::conf': class { 'puppetdb': disable_ssl => true, manage_firewall => false, - database => 'embedded', } EOS From 4e0fe7e221ef429012c17ce128c0cf7830493d5d Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Thu, 27 Oct 2022 21:26:47 +0100 Subject: [PATCH 6/6] Try forcing psql 13 --- spec/acceptance/class_spec.rb | 50 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 786a28ad..a91c9735 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -16,9 +16,15 @@ it 'works with no errors' do pp = <<-EOS # Configure PuppetDB + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $postgres_version = '13' + } else { + $postgres_version = undef + } class { 'puppetdb': - disable_ssl => true, - manage_firewall => false, + disable_ssl => true, + manage_firewall => false, + postgres_version => $postgres_version, } # Configure Puppetboard @@ -54,9 +60,15 @@ class { 'apache': } # Configure PuppetDB + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $postgres_version = '13' + } else { + $postgres_version = undef + } class { 'puppetdb': - disable_ssl => true, - manage_firewall => false, + disable_ssl => true, + manage_firewall => false, + postgres_version => $postgres_version, } # Configure Puppetboard @@ -103,9 +115,15 @@ class { 'puppetboard': require => Class['puppetdb'], } # Configure PuppetDB + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $postgres_version = '13' + } else { + $postgres_version = undef + } class { 'puppetdb': - disable_ssl => true, - manage_firewall => false, + disable_ssl => true, + manage_firewall => false, + postgres_version => $postgres_version, } EOS @@ -143,9 +161,15 @@ class { 'puppetboard::apache::conf': ldap_url => 'ldap://puppet.example.com', } # Configure PuppetDB + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $postgres_version = '13' + } else { + $postgres_version = undef + } class { 'puppetdb': - disable_ssl => true, - manage_firewall => false, + disable_ssl => true, + manage_firewall => false, + postgres_version => $postgres_version, } EOS @@ -191,9 +215,15 @@ class { 'puppetboard::apache::conf': ldap_require_group_dn => 'cn=admins,=cn=groups,dc=puppet,dc=example,dc=com', } # Configure PuppetDB + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $postgres_version = '13' + } else { + $postgres_version = undef + } class { 'puppetdb': - disable_ssl => true, - manage_firewall => false, + disable_ssl => true, + manage_firewall => false, + postgres_version => $postgres_version, } EOS