promote develop to master #6

Merged
unkinben merged 449 commits from develop into master 2024-06-01 14:48:48 +10:00
Showing only changes of commit b6d3fc26de - Show all commits

View File

@ -1,10 +1,16 @@
# profiles::consul::server # profiles::consul::server
class profiles::consul::server ( class profiles::consul::server (
String $gossip_key, Variant[
String $primary_datacenter, Undef,
Hash $acl, String
Hash $ports, ] $gossip_key = undef,
Hash $addresses, Variant[
Undef,
String
] $primary_datacenter = undef,
Hash $acl = {},
Hash $ports = {},
Hash $addresses = {},
Boolean $members_lookup = false, Boolean $members_lookup = false,
String $members_role = undef, String $members_role = undef,
Array $consul_servers = [], Array $consul_servers = [],
@ -39,57 +45,60 @@ class profiles::consul::server (
Boolean $disable_update_check = true, Boolean $disable_update_check = true,
) { ) {
# set a datacentre/cluster name # wait for all attributes to be ready
$consul_cluster = "${::facts['country']}-${::facts['region']}" if $facts['enc_role'] == $members_role {
# set a datacentre/cluster name
$consul_cluster = "${::facts['country']}-${::facts['region']}"
# if lookup is enabled, find all the hosts in the specified role and create the servers_array # if lookup is enabled, find all the hosts in the specified role and create the servers_array
if $members_lookup { if $members_lookup {
# check that the role is also set # check that the role is also set
unless !($members_role == undef) { unless !($members_role == undef) {
fail("members_role must be provided for ${title} when members_lookup is True") fail("members_role must be provided for ${title} when members_lookup is True")
}
# 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'))
# else use provided array from params
}else{
$servers_array = $consul_servers
} }
# if it is, find hosts, sort them so they dont cause changes every run # if $data_dir starts with /data, ensure the data mount exists
$servers_array = sort(query_nodes("enc_role='${members_role}' and region='${::facts['region']}'", 'networking.fqdn')) if ($data_dir.stdlib::start_with('/data') and $::facts['mountpoints']['/data']) or ! $data_dir.stdlib::start_with('/data') {
# else use provided array from params # install consul
}else{ class { 'consul':
$servers_array = $consul_servers install_method => $install_method,
} manage_repo => $manage_repo,
package_name => $package_name,
# if $data_dir starts with /data, ensure the data mount exists package_ensure => $package_ensure,
if ($data_dir.stdlib::start_with('/data') and $::facts['mountpoints']['/data']) or ! $data_dir.stdlib::start_with('/data') { bin_dir => $bin_dir,
config_hash => {
# install consul 'primary_datacenter' => $primary_datacenter,
class { 'consul': 'acl' => $acl,
install_method => $install_method, 'ports' => $ports,
manage_repo => $manage_repo, 'addresses' => $addresses,
package_name => $package_name, 'disable_remote_exec' => $disable_remote_exec,
package_ensure => $package_ensure, 'disable_update_check' => $disable_update_check,
bin_dir => $bin_dir, 'domain' => $domain,
config_hash => { 'bootstrap_expect' => $bootstrap_count,
'primary_datacenter' => $primary_datacenter, 'client_addr' => '0.0.0.0',
'acl' => $acl, 'data_dir' => $data_dir,
'ports' => $ports, 'datacenter' => $consul_cluster,
'addresses' => $addresses, 'log_level' => 'INFO',
'disable_remote_exec' => $disable_remote_exec, 'node_name' => $::facts['networking']['fqdn'],
'disable_update_check' => $disable_update_check, 'server' => true,
'domain' => $domain, 'ui' => $enable_ui,
'bootstrap_expect' => $bootstrap_count, 'ui_config' => { 'enabled' => $enable_ui_config },
'client_addr' => '0.0.0.0', 'performance' => { 'raft_multiplier' => $raft_multiplier },
'data_dir' => $data_dir, 'bind_addr' => $::facts['networking']['ip'],
'datacenter' => $consul_cluster, 'advertise_addr' => $::facts['networking']['ip'],
'log_level' => 'INFO', 'retry_join' => $servers_array
'node_name' => $::facts['networking']['fqdn'], },
'server' => true, }
'ui' => $enable_ui,
'ui_config' => { 'enabled' => $enable_ui_config },
'performance' => { 'raft_multiplier' => $raft_multiplier },
'bind_addr' => $::facts['networking']['ip'],
'advertise_addr' => $::facts['networking']['ip'],
'retry_join' => $servers_array
},
} }
} }