puppet-prod/site/profiles/manifests/ntp/client.pp
Ben Vincent dffc97ad4c chore: reorganise ntp server
- bump enc to match changes
- change ntp client to find servers through puppetdb query
- changed default ntp servers to publicly available nodes
2023-11-18 19:18:14 +11:00

42 lines
1.1 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',
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 {
# 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')
}
# Define the client configuration based on OS family
if $facts['os']['family'] == 'RedHat' {
class { 'chrony':
servers => $ntpserver_array,
wait_enable => $wait_enable,
wait_ensure => $wait_ensure,
}
} else {
class { 'chrony':
servers => $ntpserver_array,
}
}
}
}