- enable selecting nameservers to use by region, country or all - set default for nameservers to be region
43 lines
1.1 KiB
Puppet
43 lines
1.1 KiB
Puppet
# profiles::dns::base
|
|
class profiles::dns::base (
|
|
String $ns_role = undef,
|
|
Array $search = [],
|
|
Array $nameservers = ['8.8.8.8', '1.1.1.1'],
|
|
Enum[
|
|
'all',
|
|
'region',
|
|
'country'
|
|
] $use_ns = 'all',
|
|
){
|
|
|
|
# install bind_utils
|
|
include bind::updater
|
|
|
|
# if ns_role is set, find all hosts matching that enc_role
|
|
$nameserver_array = $ns_role ? {
|
|
undef => $nameservers,
|
|
default => $use_ns ? {
|
|
'all' => query_nodes("enc_role='${ns_role}'", 'networking.ip'),
|
|
'region' => query_nodes("enc_role='${ns_role}' and region=${facts['region']}", 'networking.ip'),
|
|
'country' => query_nodes("enc_role='${ns_role}' and country=${facts['country']}", 'networking.ip'),
|
|
}
|
|
}
|
|
|
|
# if search is undef, fallback to domainname from facts
|
|
if $search == [] {
|
|
$search_array = [$::facts['networking']['domain']]
|
|
}else{
|
|
$search_array = $search
|
|
}
|
|
|
|
# include resolvconf class
|
|
class { 'profiles::dns::resolvconf':
|
|
nameservers => sort($nameserver_array),
|
|
search_domains => sort($search_array),
|
|
}
|
|
|
|
# export dns records for client
|
|
profiles::dns::client {"${facts['networking']['fqdn']}-default":}
|
|
|
|
}
|