Added modules
This commit is contained in:
parent
c53c931217
commit
59ec520742
646 changed files with 35182 additions and 0 deletions
23
modules/ntp/manifests/config.pp
Normal file
23
modules/ntp/manifests/config.pp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
class ntp::config inherits ntp {
|
||||
|
||||
if $keys_enable {
|
||||
$directory = dirname($keys_file)
|
||||
file { $directory:
|
||||
ensure => directory,
|
||||
owner => 0,
|
||||
group => 0,
|
||||
mode => '0755',
|
||||
recurse => true,
|
||||
}
|
||||
}
|
||||
|
||||
file { $config:
|
||||
ensure => file,
|
||||
owner => 0,
|
||||
group => 0,
|
||||
mode => '0644',
|
||||
content => template($config_template),
|
||||
}
|
||||
|
||||
}
|
60
modules/ntp/manifests/init.pp
Normal file
60
modules/ntp/manifests/init.pp
Normal file
|
@ -0,0 +1,60 @@
|
|||
class ntp (
|
||||
$autoupdate = $ntp::params::autoupdate,
|
||||
$config = $ntp::params::config,
|
||||
$config_template = $ntp::params::config_template,
|
||||
$disable_monitor = $ntp::params::disable_monitor,
|
||||
$driftfile = $ntp::params::driftfile,
|
||||
$logfile = $ntp::params::logfile,
|
||||
$keys_enable = $ntp::params::keys_enable,
|
||||
$keys_file = $ntp::params::keys_file,
|
||||
$keys_controlkey = $ntp::params::keys_controlkey,
|
||||
$keys_requestkey = $ntp::params::keys_requestkey,
|
||||
$keys_trusted = $ntp::params::keys_trusted,
|
||||
$package_ensure = $ntp::params::package_ensure,
|
||||
$package_name = $ntp::params::package_name,
|
||||
$panic = $ntp::params::panic,
|
||||
$preferred_servers = $ntp::params::preferred_servers,
|
||||
$restrict = $ntp::params::restrict,
|
||||
$servers = $ntp::params::servers,
|
||||
$service_enable = $ntp::params::service_enable,
|
||||
$service_ensure = $ntp::params::service_ensure,
|
||||
$service_manage = $ntp::params::service_manage,
|
||||
$service_name = $ntp::params::service_name,
|
||||
$udlc = $ntp::params::udlc
|
||||
) inherits ntp::params {
|
||||
|
||||
validate_absolute_path($config)
|
||||
validate_string($config_template)
|
||||
validate_bool($disable_monitor)
|
||||
validate_absolute_path($driftfile)
|
||||
if $logfile { validate_absolute_path($logfile) }
|
||||
validate_bool($keys_enable)
|
||||
validate_re($keys_controlkey, ['^\d+$', ''])
|
||||
validate_re($keys_requestkey, ['^\d+$', ''])
|
||||
validate_array($keys_trusted)
|
||||
validate_string($package_ensure)
|
||||
validate_array($package_name)
|
||||
validate_bool($panic)
|
||||
validate_array($preferred_servers)
|
||||
validate_array($restrict)
|
||||
validate_array($servers)
|
||||
validate_bool($service_enable)
|
||||
validate_string($service_ensure)
|
||||
validate_bool($service_manage)
|
||||
validate_string($service_name)
|
||||
validate_bool($udlc)
|
||||
|
||||
if $autoupdate {
|
||||
notice('autoupdate parameter has been deprecated and replaced with package_ensure. Set this to latest for the same behavior as autoupdate => true.')
|
||||
}
|
||||
|
||||
# Anchor this as per #8040 - this ensures that classes won't float off and
|
||||
# mess everything up. You can read about this at:
|
||||
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
|
||||
anchor { 'ntp::begin': } ->
|
||||
class { '::ntp::install': } ->
|
||||
class { '::ntp::config': } ~>
|
||||
class { '::ntp::service': } ->
|
||||
anchor { 'ntp::end': }
|
||||
|
||||
}
|
9
modules/ntp/manifests/install.pp
Normal file
9
modules/ntp/manifests/install.pp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
class ntp::install inherits ntp {
|
||||
|
||||
package { 'ntp':
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
}
|
||||
|
||||
}
|
182
modules/ntp/manifests/params.pp
Normal file
182
modules/ntp/manifests/params.pp
Normal file
|
@ -0,0 +1,182 @@
|
|||
class ntp::params {
|
||||
|
||||
$autoupdate = false
|
||||
$config_template = 'ntp/ntp.conf.erb'
|
||||
$disable_monitor = false
|
||||
$keys_enable = false
|
||||
$keys_controlkey = ''
|
||||
$keys_requestkey = ''
|
||||
$keys_trusted = []
|
||||
$package_ensure = 'present'
|
||||
$preferred_servers = []
|
||||
$service_enable = true
|
||||
$service_ensure = 'running'
|
||||
$service_manage = true
|
||||
$udlc = false
|
||||
|
||||
# On virtual machines allow large clock skews.
|
||||
$panic = str2bool($::is_virtual) ? {
|
||||
true => false,
|
||||
default => true,
|
||||
}
|
||||
|
||||
$default_config = '/etc/ntp.conf'
|
||||
$default_keys_file = '/etc/ntp/keys'
|
||||
$default_driftfile = '/var/lib/ntp/drift'
|
||||
$default_package_name = ['ntp']
|
||||
$default_service_name = 'ntpd'
|
||||
|
||||
case $::osfamily {
|
||||
'AIX': {
|
||||
$keys_file = '/etc/ntp.keys'
|
||||
$driftfile = '/etc/ntp.drift'
|
||||
$package_name = [ 'bos.net.tcp.client' ]
|
||||
$restrict = [
|
||||
'default nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
]
|
||||
$service_name = 'xntpd'
|
||||
$servers = [
|
||||
'0.debian.pool.ntp.org iburst',
|
||||
'1.debian.pool.ntp.org iburst',
|
||||
'2.debian.pool.ntp.org iburst',
|
||||
'3.debian.pool.ntp.org iburst',
|
||||
]
|
||||
}
|
||||
'Debian': {
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$service_name = 'ntp'
|
||||
$servers = [
|
||||
'0.debian.pool.ntp.org iburst',
|
||||
'1.debian.pool.ntp.org iburst',
|
||||
'2.debian.pool.ntp.org iburst',
|
||||
'3.debian.pool.ntp.org iburst',
|
||||
]
|
||||
}
|
||||
'RedHat': {
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$servers = [
|
||||
'0.centos.pool.ntp.org',
|
||||
'1.centos.pool.ntp.org',
|
||||
'2.centos.pool.ntp.org',
|
||||
]
|
||||
}
|
||||
'SuSE': {
|
||||
$driftfile = '/var/lib/ntp/drift/ntp.drift'
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$service_name = 'ntp'
|
||||
$servers = [
|
||||
'0.opensuse.pool.ntp.org',
|
||||
'1.opensuse.pool.ntp.org',
|
||||
'2.opensuse.pool.ntp.org',
|
||||
'3.opensuse.pool.ntp.org',
|
||||
]
|
||||
}
|
||||
'FreeBSD': {
|
||||
$driftfile = '/var/db/ntpd.drift'
|
||||
$package_name = ['net/ntp']
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$servers = [
|
||||
'0.freebsd.pool.ntp.org iburst maxpoll 9',
|
||||
'1.freebsd.pool.ntp.org iburst maxpoll 9',
|
||||
'2.freebsd.pool.ntp.org iburst maxpoll 9',
|
||||
'3.freebsd.pool.ntp.org iburst maxpoll 9',
|
||||
]
|
||||
}
|
||||
'Archlinux': {
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$servers = [
|
||||
'0.pool.ntp.org',
|
||||
'1.pool.ntp.org',
|
||||
'2.pool.ntp.org',
|
||||
]
|
||||
}
|
||||
# Gentoo was added as its own $::osfamily in Facter 1.7.0
|
||||
'Gentoo': {
|
||||
$package_name = ['net-misc/ntp']
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$servers = [
|
||||
'0.gentoo.pool.ntp.org',
|
||||
'1.gentoo.pool.ntp.org',
|
||||
'2.gentoo.pool.ntp.org',
|
||||
'3.gentoo.pool.ntp.org',
|
||||
]
|
||||
}
|
||||
'Linux': {
|
||||
# Account for distributions that don't have $::osfamily specific settings.
|
||||
# Before Facter 1.7.0 Gentoo did not have its own $::osfamily
|
||||
case $::operatingsystem {
|
||||
'Gentoo': {
|
||||
$package_name = ['net-misc/ntp']
|
||||
$restrict = [
|
||||
'default kod nomodify notrap nopeer noquery',
|
||||
'-6 default kod nomodify notrap nopeer noquery',
|
||||
'127.0.0.1',
|
||||
'-6 ::1',
|
||||
]
|
||||
$servers = [
|
||||
'0.gentoo.pool.ntp.org',
|
||||
'1.gentoo.pool.ntp.org',
|
||||
'2.gentoo.pool.ntp.org',
|
||||
'3.gentoo.pool.ntp.org',
|
||||
]
|
||||
}
|
||||
default: {
|
||||
fail("The ${module_name} module is not supported on an ${::operatingsystem} distribution.")
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
|
||||
}
|
||||
}
|
||||
if $config == undef {
|
||||
$config = $default_config
|
||||
}
|
||||
if $keys_file == undef {
|
||||
$keys_file = $default_keys_file
|
||||
}
|
||||
if $drfitfile == undef {
|
||||
$driftfile = $default_driftfile
|
||||
}
|
||||
if $package_name == undef {
|
||||
$package_name = $default_package_name
|
||||
}
|
||||
if $service_name == undef {
|
||||
$service_name = $default_service_name
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
18
modules/ntp/manifests/service.pp
Normal file
18
modules/ntp/manifests/service.pp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
class ntp::service inherits ntp {
|
||||
|
||||
if ! ($service_ensure in [ 'running', 'stopped' ]) {
|
||||
fail('service_ensure parameter must be running or stopped')
|
||||
}
|
||||
|
||||
if $service_manage == true {
|
||||
service { 'ntp':
|
||||
ensure => $service_ensure,
|
||||
enable => $service_enable,
|
||||
name => $service_name,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue