Skip to content

Commit

Permalink
Merge pull request #80 from apenney/single_template
Browse files Browse the repository at this point in the history
Merge all the templates together, add a few new features to help with the merge.
  • Loading branch information
Ashley Penney committed Jul 31, 2013
2 parents c5408ae + ef93b7e commit e3feec2
Show file tree
Hide file tree
Showing 19 changed files with 448 additions and 689 deletions.
25 changes: 25 additions & 0 deletions README.markdown
Expand Up @@ -120,6 +120,26 @@ This sets the file to write ntp configuration into.

This determines which template puppet should use for the ntp configuration.

####`driftfile`

This sets the location of the driftfile for ntp.

####`keys_controlkey`

Which of the keys is used as the control key.

####`keys_enable`

Should the ntp keys functionality be enabled.

####`keys_file`

Location of the keys file.

####`keys_requestkey`

Which of the keys is used as the request key.

####`package_ensure`

This can be set to 'present' or 'latest' or a specific version to choose the
Expand All @@ -135,6 +155,11 @@ This determines if ntp should 'panic' in the event of a very large clock skew.
We set this to false if you're on a virtual machine by default as they don't
do a great job with keeping time.

####`preferred_servers`

List of ntp servers to prefer. Will append prefer for any server in this list
that also appears in the servers list.

####`restrict`

This sets the restrict options in the ntp configuration.
Expand Down
33 changes: 26 additions & 7 deletions manifests/config.pp
@@ -1,10 +1,29 @@
class ntp::config (
$config = $ntp::config,
$config_template = $ntp::config_template,
$panic = $ntp::panic,
$restrict = $ntp::restrict,
$servers = $ntp::servers,
) inherits ntp {
#
class ntp::config {

$config = $ntp::config
$config_template = $ntp::config_template
$driftfile = $ntp::driftfile
$keys_enable = $ntp::keys_enable
$keys_file = $ntp::keys_file
$keys_controlkey = $ntp::keys_controlkey
$keys_requestkey = $ntp::keys_requestkey
$keys_trusted = $ntp::keys_trusted
$panic = $ntp::panic
$preferred_servers = $ntp::preferred_servers
$restrict = $ntp::restrict
$servers = $ntp::servers

if $keys_enable {
$directory = dirname($keys_file)
file { $directory:
ensure => directory,
owner => 0,
group => 0,
mode => '0755',
recurse => true,
}
}

file { $config:
ensure => file,
Expand Down
49 changes: 37 additions & 12 deletions manifests/init.pp
@@ -1,18 +1,43 @@
class ntp (
$autoupdate = $ntp::params::autoupdate,
$config = $ntp::params::config,
$config_template = $ntp::params::config_template,
$package_ensure = $ntp::params::package_ensure,
$package_name = $ntp::params::package_name,
$panic = $ntp::params::panic,
$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,
$autoupdate = $ntp::params::autoupdate,
$config = $ntp::params::config,
$config_template = $ntp::params::config_template,
$driftfile = $ntp::params::driftfile,
$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,
) inherits ntp::params {

validate_absolute_path($config)
validate_string($config_template)
validate_absolute_path($driftfile)
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_bool($restrict)
validate_array($servers)
validate_bool($service_enable)
validate_string($service_ensure)
validate_bool($service_manage)
validate_string($service_name)

if $autoupdate {
notice('autoupdate parameter has been deprecated and replaced with package_ensure. Set this to latest for the same behavior as autoupdate => true.')
}
Expand Down
9 changes: 5 additions & 4 deletions manifests/install.pp
@@ -1,7 +1,8 @@
class ntp::install (
$package_ensure = $ntp::package_ensure,
$package_name = $ntp::package_name,
) inherits ntp {
#
class ntp::install {

$package_ensure = $ntp::package_ensure
$package_name = $ntp::package_name

package { 'ntp':
ensure => $package_ensure,
Expand Down
42 changes: 27 additions & 15 deletions manifests/params.pp
@@ -1,22 +1,29 @@
class ntp::params {

$autoupdate = false
$package_ensure = 'present'
$restrict = true
$service_enable = true
$service_ensure = 'running'
$service_manage = true
$autoupdate = false
$config_template = 'ntp/ntp.conf.erb'
$keys_enable = false
$keys_controlkey = ''
$keys_requestkey = ''
$keys_trusted = []
$package_ensure = 'present'
$preferred_servers = []
$restrict = true
$service_enable = true
$service_ensure = 'running'
$service_manage = true

# On virtual machines allow large clock skews.
$panic = $::is_virtual ? {
'true' => false,
$panic = str2bool($::is_virtual) ? {
true => false,
default => true,
}

case $::osfamily {
'Debian': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.debian.erb'
$keysfile = '/etc/ntp/keys'
$driftfile = '/var/lib/ntp/drift'
$package_name = [ 'ntp' ]
$service_name = 'ntp'
$servers = [
Expand All @@ -28,7 +35,8 @@
}
'RedHat': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.el.erb'
$driftfile = '/var/lib/ntp/drift'
$keysfile = '/etc/ntp/keys'
$package_name = [ 'ntp' ]
$service_name = 'ntpd'
$servers = [
Expand All @@ -39,7 +47,8 @@
}
'SuSE': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.suse.erb'
$driftfile = '/var/lib/ntp/drift/ntp.drift'
$keysfile = '/etc/ntp/keys'
$package_name = [ 'ntp' ]
$service_name = 'ntp'
$servers = [
Expand All @@ -51,7 +60,8 @@
}
'FreeBSD': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.freebsd.erb'
$driftfile = '/var/db/ntpd.drift'
$keysfile = '/etc/ntp/keys'
$package_name = ['net/ntp']
$service_name = 'ntpd'
$servers = [
Expand All @@ -63,8 +73,9 @@
}
'Archlinux': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.archlinux.erb'
$package_name = ['ntp']
$driftfile = '/var/lib/ntp/drift'
$keysfile = '/etc/ntp/keys'
$package_name = [ 'ntp' ]
$service_name = 'ntpd'
$servers = [
'0.pool.ntp.org',
Expand All @@ -77,7 +88,8 @@
case $::operatingsystem {
'Gentoo': {
$config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.gentoo.erb'
$driftfile = '/var/lib/ntp/drift'
$keysfile = '/etc/ntp/keys'
$package_name = ['net-misc/ntp']
$service_name = 'ntpd'
$servers = [
Expand Down
13 changes: 7 additions & 6 deletions manifests/service.pp
@@ -1,9 +1,10 @@
class ntp::service (
$service_enable = $ntp::service_enable,
$service_ensure = $ntp::service_ensure,
$service_manage = $ntp::service_manage,
$service_name = $ntp::service_name,
) inherits ntp {
#
class ntp::service {

$service_enable = $ntp::service_enable
$service_ensure = $ntp::service_ensure
$service_manage = $ntp::service_manage
$service_name = $ntp::service_name

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

0 comments on commit e3feec2

Please sign in to comment.