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
|
- timezone
|
||||||
|
|
||||||
profiles::ntp::client::ntp_role: 'roles::infra::ntp::server'
|
profiles::ntp::client::ntp_role: 'roles::infra::ntp::server'
|
||||||
|
profiles::ntp::client::use_ntp: 'region'
|
||||||
profiles::ntp::client::peers:
|
profiles::ntp::client::peers:
|
||||||
- 0.pool.ntp.org
|
- 0.pool.ntp.org
|
||||||
- 1.pool.ntp.org
|
- 1.pool.ntp.org
|
||||||
|
|||||||
@ -11,6 +11,11 @@ class profiles::ntp::client (
|
|||||||
'running',
|
'running',
|
||||||
'stopped'
|
'stopped'
|
||||||
] $wait_ensure = 'running',
|
] $wait_ensure = 'running',
|
||||||
|
Enum[
|
||||||
|
'all',
|
||||||
|
'region',
|
||||||
|
'country'
|
||||||
|
] $use_ntp = 'all',
|
||||||
Boolean $client_only = true,
|
Boolean $client_only = true,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -18,23 +23,25 @@ class profiles::ntp::client (
|
|||||||
# through the profiles::ntp::server class.
|
# through the profiles::ntp::server class.
|
||||||
if $client_only {
|
if $client_only {
|
||||||
|
|
||||||
# if ntp_role is set, find all hosts matching that enc_role
|
$ntpserver_array = $ntp_role ? {
|
||||||
if $ntp_role == undef {
|
undef => $peers,
|
||||||
$ntpserver_array = $peers
|
default => $use_ntp ? {
|
||||||
}else{
|
'all' => query_nodes("enc_role='${ntp_role}'", 'networking.fqdn'),
|
||||||
$ntpserver_array = 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
|
# Define the client configuration based on OS family
|
||||||
if $facts['os']['family'] == 'RedHat' {
|
if $facts['os']['family'] == 'RedHat' {
|
||||||
class { 'chrony':
|
class { 'chrony':
|
||||||
servers => $ntpserver_array,
|
servers => sort($ntpserver_array),
|
||||||
wait_enable => $wait_enable,
|
wait_enable => $wait_enable,
|
||||||
wait_ensure => $wait_ensure,
|
wait_ensure => $wait_ensure,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
class { 'chrony':
|
class { 'chrony':
|
||||||
servers => $ntpserver_array,
|
servers => sort($ntpserver_array),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user