feat: update consul/dnsmasq (#274)

- update params with bind/advertise addr
- update params with anycast ip option
- migrate dnsmasq config to template

Reviewed-on: https://git.query.consul/unkinben/puppet-prod/pulls/274
This commit is contained in:
Ben Vincent 2025-05-03 23:51:29 +10:00
parent 3079f7d000
commit a70b6492b0
2 changed files with 12 additions and 3 deletions

View File

@ -45,6 +45,9 @@ class profiles::consul::server (
Boolean $disable_update_check = true,
Boolean $join_remote_regions = false,
Array[String] $remote_regions = [],
Stdlib::IP::Address $bind_addr = $facts['networking']['ip'],
Stdlib::IP::Address $advertise_addr = $facts['networking']['ip'],
Optional[Stdlib::IP::Address] $anycast_ip = undef,
) {
# wait for all attributes to be ready
@ -112,8 +115,8 @@ class profiles::consul::server (
'ui' => $enable_ui,
'ui_config' => { 'enabled' => $enable_ui_config },
'performance' => { 'raft_multiplier' => $raft_multiplier },
'bind_addr' => $::facts['networking']['ip'],
'advertise_addr' => $::facts['networking']['ip'],
'bind_addr' => $bind_addr,
'advertise_addr' => $advertise_addr,
'retry_join' => $servers_array,
'retry_join_wan' => $remote_servers_array,
},
@ -143,7 +146,7 @@ class profiles::consul::server (
owner => 'root',
group => 'root',
mode => '0644',
content => "server=/${domain}/${::facts['networking']['ip']}#${dns_port}\n",
content => template('profiles/consul/dnsmasq.conf.erb'),
require => Package['dnsmasq'],
notify => Service['dnsmasq'],
}

View File

@ -0,0 +1,6 @@
server=/<%= @domain %>/<%= @bind_addr %>#<%= @dns_port %>
<% if @anycast_ip -%>
listen-addr=<%= @anycast_ip %>
<% else -%>
listen-addr=<%= @bind_addr %>
<% end -%>