Puppet Class: ntp::config
- Inherits:
- ntp::params
- Defined in:
- manifests/config.pp
Overview
Class: ntp::config
Configure the ntp server
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'manifests/config.pp', line 6
class ntp::config
(
$ensure,
Array[String] $ntp_servers,
Optional[Array[String]] $ntp_pools,
Optional[String] $peer,
Optional[Integer] $orphan_stratum,
Optional[Array[String]] $restrict_addresses
) inherits ntp::params
{
if ($ntp_servers) or ($ntp_pools) {
# Fine, do nothing
} else {
fail('ERROR: neither $ntp_servers or $ntp_pools parameter defined!')
}
# Check that we have extra restrict lines
if $restrict_addresses {
$restrict_lines = $restrict_addresses
} else {
$restrict_lines = undef
}
# Check if a peer is defined (for servers)
if $peer {
$peer_line = "peer ${peer}"
} else {
$peer_line = undef
}
# Check if orphan mode is activated (for servers)
if $orphan_stratum {
$orphan_line = "tos orphan ${orphan_stratum}"
} else {
$orphan_line = undef
}
$ensure_file = $ensure ? {
/(present|running)/ => 'present',
'absent' => 'absent',
}
file { 'ntp-ntp.conf':
ensure => $ensure_file,
name => '/etc/ntp.conf',
content => template('ntp/ntp.conf.erb'),
owner => $::os::params::adminuser,
group => $::os::params::admingroup,
mode => '0644',
require => Class['ntp::install'],
notify => Class['ntp::service'],
}
if $::osfamily == 'RedHat' {
include ::ntp::config::redhat
}
}
|