ae256b7c0b
ci/woodpecker/pr/erb-validate Pipeline was successful
ci/woodpecker/pr/ruby-validate Pipeline was successful
ci/woodpecker/pr/puppet-lint Pipeline was successful
ci/woodpecker/pr/yamllint Pipeline was successful
ci/woodpecker/pr/bolt-validate Pipeline was successful
ci/woodpecker/pr/epp-validate Pipeline was successful
ci/woodpecker/pr/puppet-validate Pipeline was successful
ci/woodpecker/pr/ruby-check Pipeline was successful
Replace deprecated dalen-puppetdbquery module with native puppetdb_query function using PQL syntax to resolve URI.escape compatibility issues. This is required to migrated to Puppet 8 (and kubernetes). Changes: - Remove dalen-puppetdbquery dependency from Puppetfile - Replace query_nodes() calls with puppetdb_query() using PQL syntax - Update 27 function calls across 18 Puppet manifests - Maintain equivalent functionality with improved compatibility
71 lines
2.5 KiB
Puppet
71 lines
2.5 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| {
|
|
$parts = split($cname, '\.')
|
|
$domain = join($parts[1, $parts.length], '.')
|
|
profiles::dns::record { "${::facts['networking']['fqdn']}_${cname}_CNAME":
|
|
value => "${location_environment}-halb",
|
|
type => 'CNAME',
|
|
record => "${cname}.",
|
|
zone => $domain,
|
|
order => $order,
|
|
}
|
|
}
|
|
|
|
# if it is, find hosts, sort them so they dont cause changes every run
|
|
$servers_array = sort(puppetdb_query(
|
|
"facts[certname] {
|
|
name = 'enc_role' and value = '${facts['enc_role']}' and
|
|
certname in facts[certname] { name = 'country' and value = '${facts['country']}' } and
|
|
certname in facts[certname] { name = 'region' and value = '${facts['region']}' } and
|
|
certname in facts[certname] { name = 'environment' and value = '${facts['environment']}' }
|
|
}"
|
|
).map |$fact| { $fact['certname'] })
|
|
|
|
# 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'] {
|
|
['main.unkin.net', 'unkin.net'].each |$domain| {
|
|
profiles::dns::record { "${facts['networking']['fqdn']}_vrrp_${domain}_${location_environment}-halb-vrrp":
|
|
value => $ipaddr,
|
|
type => 'A',
|
|
record => "${location_environment}-halb-vrrp",
|
|
zone => $domain,
|
|
order => $order,
|
|
}
|
|
}
|
|
|
|
$vrrp_cnames.each |$cname| {
|
|
$parts = split($cname, '\.')
|
|
$domain = join($parts[1, $parts.length], '.')
|
|
profiles::dns::record { "${::facts['networking']['fqdn']}_${cname}_CNAME":
|
|
value => "${location_environment}-halb-vrrp",
|
|
type => 'CNAME',
|
|
record => "${cname}.",
|
|
zone => $domain,
|
|
order => $order,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|