- add basic haproxy2 role - add peers and resolvers - add haproxy2+ metrics frontend
64 lines
2.1 KiB
Puppet
64 lines
2.1 KiB
Puppet
# profiles::haproxy::dns
|
|
class profiles::haproxy::dns (
|
|
Stdlib::IP::Address $ipaddr,
|
|
Array[Stdlib::Fqdn] $vrrp_cnames = [],
|
|
Array[Stdlib::Fqdn] $cnames = [],
|
|
Integer $order = 10,
|
|
){
|
|
|
|
# create an A record for each load balancer in a region
|
|
$location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}"
|
|
profiles::dns::record { "${facts['networking']['fqdn']}_${location_environment}-halb_A":
|
|
value => $::facts['networking']['ip'],
|
|
type => 'A',
|
|
record => "${location_environment}-halb",
|
|
zone => $::facts['networking']['domain'],
|
|
order => $order,
|
|
}
|
|
|
|
# export cnames for haproxy applications
|
|
$cnames.each |$cname| {
|
|
profiles::dns::record { "${::facts['networking']['fqdn']}_${cname}_CNAME":
|
|
value => "${location_environment}-halb",
|
|
type => 'CNAME',
|
|
record => "${cname}.",
|
|
zone => $::facts['networking']['domain'],
|
|
order => $order,
|
|
}
|
|
}
|
|
|
|
# if it is, find hosts, sort them so they dont cause changes every run
|
|
$servers_array = sort(query_nodes(
|
|
"enc_role='${facts['enc_role']}' and
|
|
country='${facts['country']}' and
|
|
region='${facts['region']}' and
|
|
environment='${facts['environment']}'",
|
|
'networking.fqdn'
|
|
))
|
|
|
|
# give enough time for a few hosts to be provisioned
|
|
if length($servers_array) >= 3 {
|
|
|
|
# if this is the first host in the returned filter, export a/cnames for haproxy applications
|
|
if $servers_array[0] == $trusted['certname'] {
|
|
profiles::dns::record { "${facts['networking']['fqdn']}_vrrp_${location_environment}-halb-vrrp":
|
|
value => $ipaddr,
|
|
type => 'A',
|
|
record => "${location_environment}-halb-vrrp",
|
|
zone => $::facts['networking']['domain'],
|
|
order => $order,
|
|
}
|
|
|
|
$vrrp_cnames.each |$cname| {
|
|
profiles::dns::record { "${::facts['networking']['fqdn']}_${cname}_CNAME":
|
|
value => "${location_environment}-halb-vrrp",
|
|
type => 'CNAME',
|
|
record => "${cname}.",
|
|
zone => $::facts['networking']['domain'],
|
|
order => $order,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|