From 811757314778938bb7b27fee428f5389ad7091b3 Mon Sep 17 00:00:00 2001 From: Henri Nougayrede Date: Wed, 24 Jan 2024 12:35:46 +0100 Subject: [PATCH] Add the ability to install pdns and recursor with differents versions --- manifests/init.pp | 3 ++- manifests/params.pp | 3 ++- manifests/repo.pp | 15 ++++++++------- spec/classes/powerdns_init_spec.rb | 14 ++++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8afa530..278f104 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -27,7 +27,8 @@ Powerdns::Secret $ldap_secret = undef, Boolean $custom_repo = false, Boolean $custom_epel = false, - Pattern[/4\.[0-9]+/] $version = $powerdns::params::version, + Pattern[/4\.[0-9]+/] $authoritative_version = $powerdns::params::authoritative_version, + Pattern[/[4,5]\.[0-9]+/] $recursor_version = $powerdns::params::recursor_version, String[1] $mysql_schema_file = $powerdns::params::mysql_schema_file, String[1] $pgsql_schema_file = $powerdns::params::pgsql_schema_file, Hash $forward_zones = {}, diff --git a/manifests/params.pp b/manifests/params.pp index b7666f1..f0fb274 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,7 +1,8 @@ # powerdns::params class powerdns::params { $default_package_ensure = installed - $version = '4.2' + $authoritative_version = '4.8' + $recursor_version = '4.9' case $facts['os']['family'] { 'RedHat': { diff --git a/manifests/repo.pp b/manifests/repo.pp index 52ce2d4..69b490b 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -2,7 +2,8 @@ class powerdns::repo inherits powerdns { # The repositories of PowerDNS use a version such as '40' for version 4.0 # and 41 for version 4.1. - $short_version = regsubst($powerdns::version, /^(\d)\.(\d)$/, '\\1\\2', 'G') + $authoritative_short_version = regsubst($powerdns::authoritative_version, /^(\d)\.(\d)$/, '\\1\\2', 'G') + $recursor_short_version = regsubst($powerdns::recursor_version, /^(\d)\.(\d)$/, '\\1\\2', 'G') case $facts['os']['family'] { 'RedHat': { @@ -41,8 +42,8 @@ yumrepo { 'powerdns': name => 'powerdns', - descr => "PowerDNS repository for PowerDNS Authoritative - version ${powerdns::version}", - baseurl => "http://repo.powerdns.com/centos/\$basearch/\$releasever/auth-${short_version}", + descr => "PowerDNS repository for PowerDNS Authoritative - version ${powerdns::authoritative_version}", + baseurl => "http://repo.powerdns.com/centos/\$basearch/\$releasever/auth-${authoritative_short_version}", gpgkey => 'https://repo.powerdns.com/FD380FBB-pub.asc', gpgcheck => 1, enabled => 1, @@ -52,8 +53,8 @@ yumrepo { 'powerdns-recursor': name => 'powerdns-recursor', - descr => "PowerDNS repository for PowerDNS Recursor - version ${powerdns::version}", - baseurl => "http://repo.powerdns.com/centos/\$basearch/\$releasever/rec-${short_version}", + descr => "PowerDNS repository for PowerDNS Recursor - version ${powerdns::recursor_version}", + baseurl => "http://repo.powerdns.com/centos/\$basearch/\$releasever/rec-${recursor_short_version}", gpgkey => 'https://repo.powerdns.com/FD380FBB-pub.asc', gpgcheck => 1, enabled => 1, @@ -77,7 +78,7 @@ ensure => present, location => "http://repo.powerdns.com/${os}", repos => 'main', - release => "${facts['os']['distro']['codename']}-auth-${short_version}", + release => "${facts['os']['distro']['codename']}-auth-${authoritative_short_version}", architecture => 'amd64', require => Apt::Key['powerdns'], } @@ -86,7 +87,7 @@ ensure => present, location => "http://repo.powerdns.com/${os}", repos => 'main', - release => "${facts['os']['distro']['codename']}-rec-${short_version}", + release => "${facts['os']['distro']['codename']}-rec-${recursor_short_version}", architecture => 'amd64', require => Apt::Source['powerdns'], } diff --git a/spec/classes/powerdns_init_spec.rb b/spec/classes/powerdns_init_spec.rb index 181a436..95ac9b1 100644 --- a/spec/classes/powerdns_init_spec.rb +++ b/spec/classes/powerdns_init_spec.rb @@ -129,18 +129,18 @@ } end it { is_expected.to contain_yumrepo('powerdns') } - it { is_expected.to contain_yumrepo('powerdns').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/auth-42') } + it { is_expected.to contain_yumrepo('powerdns').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/auth-48') } it { is_expected.to contain_yumrepo('powerdns-recursor') } - it { is_expected.to contain_yumrepo('powerdns-recursor').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-42') } + it { is_expected.to contain_yumrepo('powerdns-recursor').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-49') } end case facts[:osfamily] when 'Debian' it { is_expected.to contain_apt__key('powerdns') } it { is_expected.to contain_apt__pin('powerdns') } it { is_expected.to contain_apt__source('powerdns') } - it { is_expected.to contain_apt__source('powerdns').with_release(%r{auth-42}) } + it { is_expected.to contain_apt__source('powerdns').with_release(%r{auth-48}) } it { is_expected.to contain_apt__source('powerdns-recursor') } - it { is_expected.to contain_apt__source('powerdns-recursor').with_release(%r{rec-42}) } + it { is_expected.to contain_apt__source('powerdns-recursor').with_release(%r{rec-49}) } # On Ubuntu 17.04 and higher and Debian 9 and higher it expects dirmngr if (facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemmajrelease].to_i >= 17) || @@ -199,7 +199,8 @@ db_root_password: 'foobar', db_username: 'foo', db_password: 'bar', - version: '4.0' + recursor_version: '4.0', + authoritative_version: '4.0' } end @@ -563,7 +564,8 @@ db_root_password: 'foobar', db_username: 'foo', db_password: 'bar', - version: '4.7' + authoritative_version: '4.7', + recursor_version: '4.7' } end