Files
puppet-prod/site/profiles/manifests/ntp/client.pp
T
unkinben ae256b7c0b
ci/woodpecker/pr/erb-validate Pipeline was successful
ci/woodpecker/pr/ruby-validate Pipeline was successful
ci/woodpecker/pr/puppet-lint Pipeline was successful
ci/woodpecker/pr/yamllint Pipeline was successful
ci/woodpecker/pr/bolt-validate Pipeline was successful
ci/woodpecker/pr/epp-validate Pipeline was successful
ci/woodpecker/pr/puppet-validate Pipeline was successful
ci/woodpecker/pr/ruby-check Pipeline was successful
fix: replace puppetdbquery with native PQL queries
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
2026-03-21 22:16:06 +11:00

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),
}
}
}
}