476c8115c5
Replace deprecated dalen-puppetdbquery module with native puppetdb_query function using PQL syntax to resolve URI.escape compatibility issues. This is required to migrated to Puppet 8 (and kubernetes). Changes: - Remove dalen-puppetdbquery dependency from Puppetfile - Replace query_nodes() calls with puppetdb_query() using PQL syntax - Update 27 function calls across 18 Puppet manifests - Maintain equivalent functionality with improved compatibility Reviewed-on: #457
61 lines
1.7 KiB
Puppet
61 lines
1.7 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' => puppetdb_query(
|
|
"facts[certname] { name = 'enc_role' and value = '${ntp_role}' }"
|
|
).map |$fact| { $fact['certname'] },
|
|
'region' => puppetdb_query(
|
|
"facts[certname] {
|
|
name = 'enc_role' and value = '${ntp_role}' and
|
|
certname in facts[certname] { name = 'region' and value = '${facts['region']}' }
|
|
}"
|
|
).map |$fact| { $fact['certname'] },
|
|
'country' => puppetdb_query(
|
|
"facts[certname] {
|
|
name = 'enc_role' and value = '${ntp_role}' and
|
|
certname in facts[certname] { name = 'country' and value = '${facts['country']}' }
|
|
}"
|
|
).map |$fact| { $fact['certname'] },
|
|
}
|
|
}
|
|
|
|
# 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),
|
|
}
|
|
}
|
|
}
|
|
}
|