-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathinit.pp
87 lines (81 loc) · 4.41 KB
/
init.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# powerdns
#
# @param autoprimaries
# Hash of autoprimaries the ensurce (with resource powerdns_autoprimary)
# @param purge_autoprimaries
# Set this to true if you like to purge all autoprimaries not managed with puppet
#
class powerdns (
Boolean $authoritative = true,
Boolean $recursor = false,
Enum['ldap', 'mysql', 'bind', 'postgresql', 'sqlite'] $backend = 'mysql',
Boolean $backend_install = true,
Boolean $backend_create_tables = true,
Powerdns::Secret $db_root_password = undef,
String[1] $db_username = 'powerdns',
Powerdns::Secret $db_password = undef,
String[1] $db_name = 'powerdns',
String[1] $db_host = 'localhost',
Integer[1] $db_port = 3306,
String[1] $db_dir = $powerdns::params::db_dir,
String[1] $db_file = $powerdns::params::db_file,
Boolean $require_db_password = true,
String[1] $ldap_host = 'ldap://localhost/',
Optional[String[1]] $ldap_basedn = undef,
String[1] $ldap_method = 'strict',
Optional[String[1]] $ldap_binddn = undef,
Powerdns::Secret $ldap_secret = undef,
Boolean $custom_repo = false,
Boolean $custom_epel = false,
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 = {},
Powerdns::Autoprimaries $autoprimaries = {},
Boolean $purge_autoprimaries = false,
) inherits powerdns::params {
# Do some additional checks. In certain cases, some parameters are no longer optional.
if $authoritative {
if ($powerdns::backend != 'bind') and ($powerdns::backend != 'ldap') and ($powerdns::backend != 'sqlite') and $require_db_password {
assert_type(Variant[String[1], Sensitive[String[1]]], $db_password) |$expected, $actual| {
fail("'db_password' must be a non-empty string when 'authoritative' == true")
}
if $backend_install {
assert_type(Variant[String[1], Sensitive[String[1]]], $db_root_password) |$expected, $actual| {
fail("'db_root_password' must be a non-empty string when 'backend_install' == true")
}
}
}
if $backend_create_tables and $backend == 'mysql' {
assert_type(Variant[String[1], Sensitive[String[1]]], $db_root_password) |$expected, $actual| {
fail("On MySQL 'db_root_password' must be a non-empty string when 'backend_create_tables' == true")
}
}
}
# Include the required classes
unless $custom_repo {
contain powerdns::repo
}
if $authoritative {
contain powerdns::authoritative
# Set up Hiera. Even though it's not necessary to explicitly set $type for the authoritative
# config, it is added for clarity.
$powerdns_auth_config = lookup('powerdns::auth::config', Hash, 'deep', {})
$powerdns_auth_defaults = { 'type' => 'authoritative' }
create_resources(powerdns::config, $powerdns_auth_config, $powerdns_auth_defaults)
}
if $recursor {
contain powerdns::recursor
# Set up Hiera for the recursor.
$powerdns_recursor_config = lookup('powerdns::recursor::config', Hash, 'deep', {})
$powerdns_recursor_defaults = { 'type' => 'recursor' }
create_resources(powerdns::config, $powerdns_recursor_config, $powerdns_recursor_defaults)
}
if $purge_autoprimaries {
resources { 'powerdns_autoprimary':
purge => true,
}
}
create_resources('powerdns_autoprimary', $autoprimaries)
}