Skip to content

Commit

Permalink
Merge pull request #163 from mouchymouchy/main
Browse files Browse the repository at this point in the history
Add the ability to install pdns and recursor with differents versions
  • Loading branch information
ju5t authored Feb 6, 2024
2 parents 9608f86 + 8117573 commit dd6d761
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand Down
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
@@ -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': {
Expand Down
15 changes: 8 additions & 7 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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'],
}
Expand All @@ -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'],
}
Expand Down
14 changes: 8 additions & 6 deletions spec/classes/powerdns_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit dd6d761

Please sign in to comment.