Skip to content

Commit

Permalink
Merge pull request #159 from bastelfreak/archlinux
Browse files Browse the repository at this point in the history
Add Arch Linux support
  • Loading branch information
ju5t authored Aug 22, 2023
2 parents 457b065 + 3950bb0 commit fbb1623
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
22 changes: 22 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
Apt::Pin['powerdns'] -> Package <| title == $powerdns::params::recursor_package |>
}

'FreeBSD': {
'FreeBSD','Archlinux': {
# Use the official pkg repository
}

Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
"operatingsystemrelease": [
"10"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
Expand Down
36 changes: 25 additions & 11 deletions spec/classes/powerdns_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ]) }

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

Expand All @@ -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',
Expand Down Expand Up @@ -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') }
Expand Down Expand Up @@ -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') }
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/powerdns_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fbb1623

Please sign in to comment.