feat: sort ntpservers, select ntp to use
- sort the ntpservers array so it doesnt change each run of puppet - allow the selection of all, region or country specific ntp servers
This commit is contained in:
parent
e5b3112189
commit
7b316c6b0b
@ -46,6 +46,7 @@ hiera_classes:
|
||||
- timezone
|
||||
|
||||
profiles::ntp::client::ntp_role: 'roles::infra::ntp::server'
|
||||
profiles::ntp::client::use_ntp: 'region'
|
||||
profiles::ntp::client::peers:
|
||||
- 0.pool.ntp.org
|
||||
- 1.pool.ntp.org
|
||||
|
||||
@ -11,6 +11,11 @@ class profiles::ntp::client (
|
||||
'running',
|
||||
'stopped'
|
||||
] $wait_ensure = 'running',
|
||||
Enum[
|
||||
'all',
|
||||
'region',
|
||||
'country'
|
||||
] $use_ntp = 'all',
|
||||
Boolean $client_only = true,
|
||||
) {
|
||||
|
||||
@ -18,23 +23,25 @@ class profiles::ntp::client (
|
||||
# through the profiles::ntp::server class.
|
||||
if $client_only {
|
||||
|
||||
# if ntp_role is set, find all hosts matching that enc_role
|
||||
if $ntp_role == undef {
|
||||
$ntpserver_array = $peers
|
||||
}else{
|
||||
$ntpserver_array = query_nodes("enc_role='${ntp_role}'", 'networking.fqdn')
|
||||
$ntpserver_array = $ntp_role ? {
|
||||
undef => $peers,
|
||||
default => $use_ntp ? {
|
||||
'all' => query_nodes("enc_role='${ntp_role}'", 'networking.fqdn'),
|
||||
'region' => query_nodes("enc_role='${ntp_role}' and region=${facts['region']}", 'networking.fqdn'),
|
||||
'country' => query_nodes("enc_role='${ntp_role}' and country=${facts['country']}", 'networking.fqdn'),
|
||||
}
|
||||
}
|
||||
|
||||
# Define the client configuration based on OS family
|
||||
if $facts['os']['family'] == 'RedHat' {
|
||||
class { 'chrony':
|
||||
servers => $ntpserver_array,
|
||||
servers => sort($ntpserver_array),
|
||||
wait_enable => $wait_enable,
|
||||
wait_ensure => $wait_ensure,
|
||||
}
|
||||
} else {
|
||||
class { 'chrony':
|
||||
servers => $ntpserver_array,
|
||||
servers => sort($ntpserver_array),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user