|
13 | 13 | #
|
14 | 14 | # Parameters:
|
15 | 15 | #
|
16 |
| -# $servers = [ "0.debian.pool.ntp.org iburst", |
17 |
| -# "1.debian.pool.ntp.org iburst", |
18 |
| -# "2.debian.pool.ntp.org iburst", |
19 |
| -# "3.debian.pool.ntp.org iburst", ] |
| 16 | +# $servers = [ '0.debian.pool.ntp.org iburst', |
| 17 | +# '1.debian.pool.ntp.org iburst', |
| 18 | +# '2.debian.pool.ntp.org iburst', |
| 19 | +# '3.debian.pool.ntp.org iburst', ] |
20 | 20 | #
|
21 | 21 | # Actions:
|
22 | 22 | #
|
|
32 | 32 | # }
|
33 | 33 | #
|
34 | 34 | # [Remember: No empty lines between comments and class definition]
|
35 |
| -class ntp($servers="UNSET", |
36 |
| - $ensure="running", |
| 35 | +class ntp($servers='UNSET', |
| 36 | + $ensure='running', |
37 | 37 | $autoupdate=false
|
38 | 38 | ) {
|
39 | 39 |
|
40 |
| - if ! ($ensure in [ "running", "stopped" ]) { |
41 |
| - fail("ensure parameter must be running or stopped") |
| 40 | + if ! ($ensure in [ 'running', 'stopped' ]) { |
| 41 | + fail('ensure parameter must be running or stopped') |
42 | 42 | }
|
43 | 43 |
|
44 | 44 | if $autoupdate == true {
|
45 | 45 | $package_ensure = latest
|
46 | 46 | } elsif $autoupdate == false {
|
47 | 47 | $package_ensure = present
|
48 | 48 | } else {
|
49 |
| - fail("autoupdate parameter must be true or false") |
| 49 | + fail('autoupdate parameter must be true or false') |
50 | 50 | }
|
51 | 51 |
|
52 | 52 | case $::operatingsystem {
|
53 | 53 | debian, ubuntu: {
|
54 | 54 | $supported = true
|
55 |
| - $pkg_name = [ "ntp" ] |
56 |
| - $svc_name = "ntp" |
57 |
| - $config = "/etc/ntp.conf" |
58 |
| - $config_tpl = "ntp.conf.debian.erb" |
59 |
| - if ($servers == "UNSET") { |
60 |
| - $servers_real = [ "0.debian.pool.ntp.org iburst", |
61 |
| - "1.debian.pool.ntp.org iburst", |
62 |
| - "2.debian.pool.ntp.org iburst", |
63 |
| - "3.debian.pool.ntp.org iburst", ] |
| 55 | + $pkg_name = [ 'ntp' ] |
| 56 | + $svc_name = 'ntp' |
| 57 | + $config = '/etc/ntp.conf' |
| 58 | + $config_tpl = 'ntp.conf.debian.erb' |
| 59 | + if ($servers == 'UNSET') { |
| 60 | + $servers_real = [ '0.debian.pool.ntp.org iburst', |
| 61 | + '1.debian.pool.ntp.org iburst', |
| 62 | + '2.debian.pool.ntp.org iburst', |
| 63 | + '3.debian.pool.ntp.org iburst', ] |
64 | 64 | } else {
|
65 | 65 | $servers_real = $servers
|
66 | 66 | }
|
67 | 67 | }
|
68 | 68 | centos, redhat, oel, linux: {
|
69 | 69 | $supported = true
|
70 |
| - $pkg_name = [ "ntp" ] |
71 |
| - $svc_name = "ntpd" |
72 |
| - $config = "/etc/ntp.conf" |
73 |
| - $config_tpl = "ntp.conf.el.erb" |
74 |
| - if ($servers == "UNSET") { |
75 |
| - $servers_real = [ "0.centos.pool.ntp.org", |
76 |
| - "1.centos.pool.ntp.org", |
77 |
| - "2.centos.pool.ntp.org", ] |
| 70 | + $pkg_name = [ 'ntp' ] |
| 71 | + $svc_name = 'ntpd' |
| 72 | + $config = '/etc/ntp.conf' |
| 73 | + $config_tpl = 'ntp.conf.el.erb' |
| 74 | + if ($servers == 'UNSET') { |
| 75 | + $servers_real = [ '0.centos.pool.ntp.org', |
| 76 | + '1.centos.pool.ntp.org', |
| 77 | + '2.centos.pool.ntp.org', ] |
78 | 78 | } else {
|
79 | 79 | $servers_real = $servers
|
80 | 80 | }
|
81 | 81 | }
|
82 | 82 | freebsd: {
|
83 | 83 | $supported = true
|
84 |
| - $pkg_name = [".*/net/ntp"] |
85 |
| - $svc_name = "ntpd" |
86 |
| - $config = "/etc/ntp.conf" |
87 |
| - $config_tpl = "ntp.conf.freebsd.erb" |
88 |
| - if ($servers == "UNSET") { |
89 |
| - $servers_real = [ "0.freebsd.pool.ntp.org iburst maxpoll 9", |
90 |
| - "1.freebsd.pool.ntp.org iburst maxpoll 9", |
91 |
| - "2.freebsd.pool.ntp.org iburst maxpoll 9", |
92 |
| - "3.freebsd.pool.ntp.org iburst maxpoll 9", ] |
| 84 | + $pkg_name = ['.*/net/ntp'] |
| 85 | + $svc_name = 'ntpd' |
| 86 | + $config = '/etc/ntp.conf' |
| 87 | + $config_tpl = 'ntp.conf.freebsd.erb' |
| 88 | + if ($servers == 'UNSET') { |
| 89 | + $servers_real = [ '0.freebsd.pool.ntp.org iburst maxpoll 9', |
| 90 | + '1.freebsd.pool.ntp.org iburst maxpoll 9', |
| 91 | + '2.freebsd.pool.ntp.org iburst maxpoll 9', |
| 92 | + '3.freebsd.pool.ntp.org iburst maxpoll 9', ] |
93 | 93 | } else {
|
94 | 94 | $servers_real = $servers
|
95 | 95 | }
|
|
104 | 104 |
|
105 | 105 | if ($supported == true) {
|
106 | 106 |
|
107 |
| - package { "ntp": |
| 107 | + package { 'ntp': |
108 | 108 | name => $pkg_name,
|
109 | 109 | ensure => $package_ensure,
|
110 | 110 | }
|
111 | 111 |
|
112 | 112 | file { $config:
|
113 |
| - ensure => file, |
114 |
| - owner => 0, |
115 |
| - group => 0, |
116 |
| - mode => 0644, |
| 113 | + ensure => file, |
| 114 | + owner => 0, |
| 115 | + group => 0, |
| 116 | + mode => '0644', |
117 | 117 | content => template("${module_name}/${config_tpl}"),
|
118 | 118 | require => Package[$pkg_name],
|
119 | 119 | }
|
120 | 120 |
|
121 |
| - service { "ntp": |
| 121 | + service { 'ntp': |
122 | 122 | ensure => $ensure,
|
123 | 123 | name => $svc_name,
|
124 | 124 | hasstatus => true,
|
125 | 125 | hasrestart => true,
|
126 | 126 | subscribe => [ Package[$pkg_name], File[$config] ],
|
127 | 127 | }
|
128 |
| - |
129 | 128 | }
|
130 |
| - |
131 | 129 | }
|
0 commit comments