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