Skip to content

Commit

Permalink
[WIP] Make IPv4 optional in proxydns
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Jul 17, 2019
1 parent 9939f88 commit f9063b8
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions manifests/proxydns.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,44 @@
$interface_fact_name = regsubst($interface, '[.:]', '_')
$ip = fact("ipaddress_${interface_fact_name}")

assert_type(Stdlib::Compat::Ipv4, $ip) |$expected, $actual| {
fail("Could not get a valid IP address from fact ipaddress_${interface_fact_name}: '${ip}' (${actual})")
}

if $reverse_zone {
$reverse = $reverse_zone
} else {
$netmask = fact("netmask_${interface_fact_name}")
assert_type(Stdlib::Compat::Ipv4, $netmask) |$expected, $actual| {
fail("Could not get a valid netmask from fact netmask_${interface_fact_name}: '${netmask}' (${actual})")
}
$reverse = foreman_proxy::get_network_in_addr($ip, $netmask)
assert_type(String[1], $reverse) |$expected, $actual| {
fail("Could not determine reverse for ${ip}/${netmask}")
if $ip {
$netmask = fact("netmask_${interface_fact_name}")
assert_type(Stdlib::Compat::Ipv4, $netmask) |$expected, $actual| {
fail("Could not get a valid netmask from fact netmask_${interface_fact_name}: '${netmask}' (${actual})")
}
$reverse = foreman_proxy::get_network_in_addr($ip, $netmask)
assert_type(String[1], $reverse) |$expected, $actual| {
fail("Could not determine reverse for ${ip}/${netmask}")
}
} else {
$reverse = undef
}
}

dns::zone { $forward_zone:
soa => $soa,
reverse => false,
soaip => $ip,
if $ip =~ Stdlib::IP::Address::V4::Nosubnet {
dns::zone { $forward_zone:
soa => $soa,
reverse => false,
soaip => $ip,
}
} else {
# We have no IPv4 which means we could be running IPv6-only. reverse =>
# true omits the IN A record, but it defaults to $facts['ipaddress'] which
# is empty in IPv6-only so we pass in something syntactically valid
dns::zone { $forward_zone:
soa => $soa,
reverse => true,
soaip => '127.0.0.1',
}
}

dns::zone { $reverse:
soa => $soa,
reverse => true,
if $reverse {
dns::zone { $reverse:
soa => $soa,
reverse => true,
}
}
}

0 comments on commit f9063b8

Please sign in to comment.