From 3950bb02a38634c38c88e28b1e26caa1a7fbb519 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 17 Sep 2022 22:44:27 +0200 Subject: [PATCH] Add Arch Linux support --- manifests/params.pp | 22 +++++++++++++++++ manifests/repo.pp | 2 +- metadata.json | 3 +++ spec/classes/powerdns_init_spec.rb | 36 +++++++++++++++++++--------- spec/defines/powerdns_config_spec.rb | 4 ++-- 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index d856e0b..b7666f1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -101,6 +101,28 @@ $recursor_config = "${recursor_dir}/recursor.conf" $install_packages = [] } + 'Archlinux': { + $authoritative_package = 'powerdns' + $authoritative_service = 'pdns' + $recursor_package = 'powerdns-recursor' + $recursor_service = 'pdns-recursor' + $mysql_schema_file = '/usr/share/doc/powerdns/schema.mysql.sql' + $pgsql_schema_file = '/usr/share/doc/powerdns/schema.pgsql.sql' + $sqlite_schema_file = '/usr/share/doc/powerdns/schema.sqlite3.sql' + $db_dir = '/var/lib/powerdns' + $db_file = "${db_dir}/powerdns.sqlite3" + $service_provider = 'systemd' + $install_packages = [] + $mysql_backend_package_name = undef + $ldap_backend_package_name = undef + $pgsql_backend_package_name = undef + $sqlite_backend_package_name = undef + $authoritative_config = '/etc/powerdns/pdns.conf' + $recursor_dir = '/etc/powerdns' + $recursor_config = "${recursor_dir}/recursor.conf" + $sqlite_package_name = 'sqlite' + $authoritative_configdir = '/etc/powerdns' + } default: { fail("${facts['os']['family']} is not supported yet.") } diff --git a/manifests/repo.pp b/manifests/repo.pp index fb1d15e..52ce2d4 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -102,7 +102,7 @@ Apt::Pin['powerdns'] -> Package <| title == $powerdns::params::recursor_package |> } - 'FreeBSD': { + 'FreeBSD','Archlinux': { # Use the official pkg repository } diff --git a/metadata.json b/metadata.json index 20e3a1c..c8bd043 100644 --- a/metadata.json +++ b/metadata.json @@ -66,6 +66,9 @@ "operatingsystemrelease": [ "10" ] + }, + { + "operatingsystem": "Archlinux" } ], "requirements": [ diff --git a/spec/classes/powerdns_init_spec.rb b/spec/classes/powerdns_init_spec.rb index 395a7ae..181a436 100644 --- a/spec/classes/powerdns_init_spec.rb +++ b/spec/classes/powerdns_init_spec.rb @@ -43,6 +43,16 @@ sqlite_binary_package_name = 'sqlite3' recursor_package_name = 'pdns-recursor' recursor_service_name = 'pdns-recursor' + when 'Archlinux' + authoritative_package_name = 'powerdns' + authoritative_service_name = 'pdns' + authoritative_config = '/etc/powerdns/pdns.conf' + mysql_schema_file = '/usr/share/doc/powerdns/schema.mysql.sql' + pgsql_schema_file = '/usr/share/doc/powerdns/schema.pgsql.sql' + sqlite_schema_file = '/usr/share/doc/powerdns/schema.sqlite3.sql' + recursor_package_name = 'powerdns-recursor' + recursor_service_name = 'pdns-recursor' + recursor_dir = '/etc/powerdns' end context 'powerdns class without parameters' do @@ -159,7 +169,7 @@ it { is_expected.to compile.with_all_deps } - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' it { is_expected.to contain_class('epel') } end @@ -218,7 +228,9 @@ end it { is_expected.to contain_class('powerdns::backends::mysql') } - it { is_expected.to contain_package('pdns-backend-mysql').with('ensure' => 'installed') } + if facts[:os]['name'] != 'Archlinux' + it { is_expected.to contain_package('pdns-backend-mysql').with('ensure' => 'installed') } + end it { is_expected.to contain_mysql__db('powerdns').with('user' => 'foo', 'password' => 'bar', 'host' => '127.0.0.1') } it { is_expected.to contain_mysql__db('powerdns').with_sql([ mysql_schema_file ]) } @@ -250,12 +262,14 @@ it { is_expected.to contain_class('powerdns::backends::postgresql') } - if facts[:operatingsystem] == 'Debian' + if facts[:os]['name'] == 'Debian' it { is_expected.to contain_file('/etc/powerdns/pdns.d/pdns.local.gpgsql.conf').with('ensure' => 'absent') } it { is_expected.to contain_package('pdns-backend-bind').with('ensure' => 'purged') } end - it { is_expected.to contain_package(pgsql_backend_package_name).with('ensure' => 'installed') } + if facts[:os]['name'] != 'Archlinux' + it { is_expected.to contain_package(pgsql_backend_package_name).with('ensure' => 'installed') } + end it { is_expected.to contain_postgresql__server__db('powerdns').with('user' => 'foo') } it { is_expected.to contain_postgresql_psql('Load SQL schema').with('command' => "\\i #{pgsql_schema_file}") } @@ -280,8 +294,10 @@ end it { is_expected.to contain_class('powerdns::backends::sqlite') } - it { is_expected.to contain_package(sqlite_backend_package_name).with('ensure' => 'installed') } - it { is_expected.to contain_package(sqlite_binary_package_name).with('ensure' => 'installed') } + if facts[:os]['name'] != 'Archlinux' + it { is_expected.to contain_package(sqlite_backend_package_name).with('ensure' => 'installed') } + it { is_expected.to contain_package(sqlite_binary_package_name).with('ensure' => 'installed') } + end it do is_expected.to contain_file('/var/lib/powerdns/db.sqlite3').with( 'ensure' => 'file', @@ -319,14 +335,12 @@ it { is_expected.to contain_class('powerdns::backends::bind') } - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' it { is_expected.to contain_file('/etc/pdns/named.conf').with('ensure' => 'file') } it { is_expected.to contain_file('/etc/pdns/named').with('ensure' => 'directory') } it { is_expected.to contain_file('/etc/pdns/pdns.d/pdns.simplebind.conf').with('ensure' => 'absent') } it { is_expected.to contain_powerdns__config('bind-config').with('value' => '/etc/pdns/named.conf') } - end - case facts[:osfamily] when 'Debian' it { is_expected.to contain_file('/etc/powerdns/named.conf').with('ensure' => 'file') } it { is_expected.to contain_file('/etc/powerdns/named').with('ensure' => 'directory') } @@ -356,8 +370,8 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('powerdns::backends::ldap') } - it { is_expected.to contain_package('pdns-backend-ldap').with('ensure' => 'installed') } - it { is_expected.to contain_package('pdns-backend-bind').with('ensure' => 'purged') } if facts[:operatingsystem] == 'Debian' + it { is_expected.to contain_package('pdns-backend-ldap').with('ensure' => 'installed') } if facts[:os]['name'] != 'Archlinux' + it { is_expected.to contain_package('pdns-backend-bind').with('ensure' => 'purged') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_powerdns__config('launch').with('value' => 'ldap') } it { is_expected.to contain_powerdns__config('ldap-host').with('value' => 'ldap://localhost/') } it { is_expected.to contain_powerdns__config('ldap-basedn').with('value' => 'ou=foo') } diff --git a/spec/defines/powerdns_config_spec.rb b/spec/defines/powerdns_config_spec.rb index 8df80ee..0f69d1e 100644 --- a/spec/defines/powerdns_config_spec.rb +++ b/spec/defines/powerdns_config_spec.rb @@ -26,11 +26,11 @@ }' end - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' authoritative_config = '/etc/pdns/pdns.conf' recursor_config = '/etc/pdns-recursor/recursor.conf' - when 'Debian' + when 'Debian', 'Archlinux' authoritative_config = '/etc/powerdns/pdns.conf' recursor_config = '/etc/powerdns/recursor.conf' end