feat: consul multi-datacentre joining
- add method to join multiple consul datacentres - set syd1 as the primary datacentre - use default token from au-syd1 cluster in all locations - add replication token
This commit is contained in:
@@ -43,6 +43,8 @@ class profiles::consul::server (
|
||||
Stdlib::Absolutepath $bin_dir = '/usr/bin',
|
||||
Boolean $disable_remote_exec = true,
|
||||
Boolean $disable_update_check = true,
|
||||
Boolean $join_remote_regions = false,
|
||||
Array[String] $remote_regions = [],
|
||||
) {
|
||||
|
||||
# wait for all attributes to be ready
|
||||
@@ -62,6 +64,21 @@ class profiles::consul::server (
|
||||
# if it is, find hosts, sort them so they dont cause changes every run
|
||||
$servers_array = sort(query_nodes("enc_role='${members_role}' and region='${::facts['region']}'", 'networking.fqdn'))
|
||||
|
||||
if $join_remote_regions {
|
||||
# get all nodes in the members_role for each other region
|
||||
$region_to_servers = $remote_regions.reduce({}) |$memo, $region| {
|
||||
$servers = sort(query_nodes("enc_role='${members_role}' and region='${region}'", 'networking.fqdn'))
|
||||
$memo + { $region => $servers }
|
||||
}
|
||||
|
||||
# sort and flatten the regions into a single array of fqdns
|
||||
$remote_servers_array = sort(flatten($region_to_servers.values))
|
||||
|
||||
} else {
|
||||
# else just send an empty array
|
||||
$remote_servers_array = []
|
||||
}
|
||||
|
||||
# else use provided array from params
|
||||
}else{
|
||||
$servers_array = $consul_servers
|
||||
@@ -97,7 +114,8 @@ class profiles::consul::server (
|
||||
'performance' => { 'raft_multiplier' => $raft_multiplier },
|
||||
'bind_addr' => $::facts['networking']['ip'],
|
||||
'advertise_addr' => $::facts['networking']['ip'],
|
||||
'retry_join' => $servers_array
|
||||
'retry_join' => $servers_array,
|
||||
'retry_join_wan' => $remote_servers_array,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user