Skip to content

Commit

Permalink
update chrony for forge
Browse files Browse the repository at this point in the history
  • Loading branch information
aboe76 committed Jul 19, 2013
1 parent 63eab3e commit 74c0dc8
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 26 deletions.
24 changes: 24 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class chrony::config (
$config = $chrony::config,
$config_template = $chrony::config_template,
$config_keys = $chrony::config_keys,
$config_keys_template = $chrony::config_keys_template,
$chrony_password = $chrony::chrony_password,
$servers = $chrony::servers,) inherits chrony {
file { $config:
ensure => file,
owner => 0,
group => 0,
mode => '0644',
content => template($config_template),
}

file { $config_keys:
ensure => file,
owner => 0,
group => 0,
mode => '0644',
content => template($config_keys_template),
}

}
55 changes: 29 additions & 26 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
class chrony (
$ntpservers = [
'0.nl.pool.ntp.org',
'1.nl.pool.ntp.org',
'2.nl.pool.ntp.org',
'3.nl.pool.ntp.org', ]
){
package { 'chrony':
ensure => present,
}
$autoupdate = $chrony::params::autoupdate,
$config = $chrony::params::config,
$config_template = $chrony::params::config_template,
$config_keys = $chrony::params::config_keys,
$config_keys_template = $chrony::params::config_keys_template,
$chrony_password = $chrony::params::chrony_password,
$package_ensure = $chrony::params::package_ensure,
$package_name = $chrony::params::package_name,
$servers = $chrony::params::servers,
$service_enable = $chrony::params::service_enable,
$service_ensure = $chrony::params::service_ensure,
$service_manage = $chrony::params::service_manage,
$service_name = $chrony::params::service_name,) inherits chrony::params {
if $autoupdate {
notice('autoupdate parameter has been deprecated and replaced with package_ensure. Set this to latest for the same behavior as autoupdate => true.'
)
}

file { '/etc/chrony.conf':
ensure => present,
owner => root,
group => root,
mode => '0644',
content => template('chrony/chrony.conf.erb'),
require => Package['chrony'],
notify => Service['chrony.service'],
}
include '::chrony::install'
include '::chrony::config'
include '::chrony::service'

# Anchor this as per #8140 - 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 { 'chrony::begin': }
anchor { 'chrony::end': }

Anchor['chrony::begin'] -> Class['::chrony::install'] -> Class['::chrony::config']
~> Class['::chrony::service'] -> Anchor['chrony::end']

service { 'chrony.service':
ensure => running,
provider => systemd,
hasstatus => true,
hasrestart => true,
enable => true,
require => Package['chrony'],
}
}
11 changes: 11 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class chrony::install (
$package_ensure = $chrony::package_ensure,
$package_name = $chrony::package_name,
) inherits chrony {

package { 'chrony':
ensure => $package_ensure,
name => $package_name,
}

}
24 changes: 24 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class chrony::params {
$autoupdate = false
$package_ensure = 'present'
$service_enable = true
$service_ensure = 'running'
$service_manage = true
$chrony_password = 'xyzzy'

case $::osfamily {
'Archlinux' : {
$config = '/etc/chrony.conf'
$config_template = 'chrony/chrony.conf.archlinux.erb'
$config_keys = 'etc/chrony.keys'
$config_keys_template = 'chrony/chrony.keys.archlinux.erb'
$package_name = ['chrony']
$service_name = 'chrony'
$servers = ['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org',]
}

default : {
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
}
}
}
22 changes: 22 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class chrony::service (
$service_enable = $chrony::service_enable,
$service_ensure = $chrony::service_ensure,
$service_manage = $chrony::service_manage,
$service_name = $chrony::service_name,
) inherits chrony {

if ! ($service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped')
}

if $service_manage == true {
service { 'chrony':
ensure => $service_ensure,
enable => $service_enable,
name => $service_name,
hasstatus => true,
hasrestart => true,
}
}

}
File renamed without changes.
1 change: 1 addition & 0 deletions templates/chrony.keys.archlinux.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 <%= chrony_password %>
11 changes: 11 additions & 0 deletions tests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node default {

notify { 'enduser-before': }
notify { 'enduser-after': }

class { 'chrony':
require => Notify['enduser-before'],
before => Notify['enduser-after'],
}

}

0 comments on commit 74c0dc8

Please sign in to comment.