- a ci workflow for build tests - run pre-commit against all files Reviewed-on: #342
49 lines
1.3 KiB
Puppet
49 lines
1.3 KiB
Puppet
# setup an ntp client using chrony
|
|
# use exported resources from profiles::ntp::server if they are available
|
|
class profiles::ntp::client (
|
|
Array $peers,
|
|
Variant[
|
|
String,
|
|
Undef
|
|
] $ntp_role = undef,
|
|
Boolean $wait_enable = true,
|
|
Enum[
|
|
'running',
|
|
'stopped'
|
|
] $wait_ensure = 'running',
|
|
Enum[
|
|
'all',
|
|
'region',
|
|
'country'
|
|
] $use_ntp = 'all',
|
|
Boolean $client_only = true,
|
|
) {
|
|
|
|
# If $client_only, setup a client. Servers are set to false so that they are configured
|
|
# through the profiles::ntp::server class.
|
|
if $client_only {
|
|
|
|
$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 => sort($ntpserver_array),
|
|
wait_enable => $wait_enable,
|
|
wait_ensure => $wait_ensure,
|
|
}
|
|
} else {
|
|
class { 'chrony':
|
|
servers => sort($ntpserver_array),
|
|
}
|
|
}
|
|
}
|
|
}
|