|
1 | 1 | class ntp (
|
2 |
| - $autoupdate, |
3 |
| - Stdlib::Compat::Bool $broadcastclient, |
4 |
| - Stdlib::Compat::Absolute_path $config, |
5 |
| - Variant[Any, Undef, Stdlib::Compat::Absolute_path] $config_dir, |
6 |
| - $config_file_mode, |
7 |
| - Stdlib::Compat::String $config_template, |
8 |
| - Stdlib::Compat::Bool $disable_auth, |
9 |
| - Stdlib::Compat::Bool $disable_dhclient, |
10 |
| - Stdlib::Compat::Bool $disable_kernel, |
11 |
| - Stdlib::Compat::Bool $disable_monitor, |
12 |
| - Stdlib::Compat::Array $fudge, |
13 |
| - Stdlib::Compat::Absolute_path $driftfile, |
14 |
| - Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $leapfile, |
15 |
| - Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $logfile, |
16 |
| - Stdlib::Compat::Bool $iburst_enable, |
17 |
| - Stdlib::Compat::Array $keys, |
18 |
| - Stdlib::Compat::Bool $keys_enable, |
19 |
| - $keys_file, |
20 |
| - Variant[Pattern['^\d+$'], Pattern['']] $keys_controlkey, |
21 |
| - Variant[Pattern['^\d+$'], Pattern['']] $keys_requestkey, |
22 |
| - Stdlib::Compat::Array $keys_trusted, |
23 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $minpoll, |
24 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $maxpoll, |
25 |
| - Stdlib::Compat::String $package_ensure, |
26 |
| - Stdlib::Compat::Bool $package_manage, |
27 |
| - Stdlib::Compat::Array $package_name, |
| 2 | + Any $autoupdate, |
| 3 | + Variant[Boolean, Stdlib::Compat::Bool] $broadcastclient, |
| 4 | + Variant[Tea::Absolutepath, Stdlib::Compat::Absolute_path] $config, |
| 5 | + Variant[Optional[Tea::Absolutepath], Any, Undef, Stdlib::Compat::Absolute_path] $config_dir, |
| 6 | + Variant[String, Any] $config_file_mode, |
| 7 | + Variant[String[1], Stdlib::Compat::String] $config_template, |
| 8 | + Variant[Boolean, Stdlib::Compat::Bool] $disable_auth, |
| 9 | + Variant[Boolean, Stdlib::Compat::Bool] $disable_dhclient, |
| 10 | + Variant[Boolean, Stdlib::Compat::Bool] $disable_kernel, |
| 11 | + Variant[Boolean, Stdlib::Compat::Bool] $disable_monitor, |
| 12 | + Variant[Optional[Array[String]], Stdlib::Compat::Array] $fudge, |
| 13 | + Variant[Tea::Absolutepath, Stdlib::Compat::Absolute_path] $driftfile, |
| 14 | + Variant[Optional[Tea::Absolutepath], Boolean, Undef, Stdlib::Compat::Absolute_path] $leapfile, |
| 15 | + Variant[Optional[Tea::Absolutepath], Boolean, Undef, Stdlib::Compat::Absolute_path] $logfile, |
| 16 | + Variant[Boolean, Stdlib::Compat::Bool] $iburst_enable, |
| 17 | + Variant[Array[String], Stdlib::Compat::Array] $keys, |
| 18 | + Variant[Boolean, Stdlib::Compat::Bool] $keys_enable, |
| 19 | + Variant[Tea::Absolutepath, Any] $keys_file, |
| 20 | + Variant[Optional[Ntp::Key_id], Pattern['^\d+$'], Pattern['']] $keys_controlkey, |
| 21 | + Variant[Optional[Ntp::Key_id], Pattern['^\d+$'], Pattern['']] $keys_requestkey, |
| 22 | + Variant[Optional[Array[Ntp::Key_id]], Stdlib::Compat::Array] $keys_trusted, |
| 23 | + Variant[Optional[Ntp::Poll_interval], Boolean, Undef, Stdlib::Compat::Numeric] $minpoll, |
| 24 | + Variant[Optional[Ntp::Poll_interval], Boolean, Undef, Stdlib::Compat::Numeric] $maxpoll, |
| 25 | + Variant[String, Stdlib::Compat::String] $package_ensure, |
| 26 | + Variant[Boolean, Stdlib::Compat::Bool] $package_manage, |
| 27 | + Variant[Array[String], Stdlib::Compat::Array] $package_name, |
28 | 28 | Variant[Boolean, Undef, Stdlib::Compat::Numeric] $panic = $ntp::params::panic,
|
29 |
| - Stdlib::Compat::Array $peers, |
30 |
| - Stdlib::Compat::Array $preferred_servers, |
31 |
| - Stdlib::Compat::Array $restrict, |
32 |
| - Stdlib::Compat::Array $interfaces, |
33 |
| - $interfaces_ignore, |
34 |
| - Stdlib::Compat::Array $servers, |
35 |
| - Stdlib::Compat::Bool $service_enable, |
36 |
| - Stdlib::Compat::String $service_ensure, |
37 |
| - Stdlib::Compat::Bool $service_manage, |
38 |
| - Stdlib::Compat::String $service_name, |
39 |
| - $service_provider, |
40 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $stepout, |
41 |
| - Variant[Boolean, Undef, Stdlib::Compat::String] $step_tickers_file, |
42 |
| - Variant[Any, Undef, Stdlib::Compat::String] $step_tickers_template, |
43 |
| - Stdlib::Compat::Bool $tinker = $ntp::params::tinker, |
44 |
| - Stdlib::Compat::Bool $tos, |
45 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_minclock, |
46 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_minsane, |
47 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_floor, |
48 |
| - Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_ceiling, |
49 |
| - Variant[Boolean, Undef, Pattern['^[0|1]$']] $tos_cohort, |
50 |
| - Stdlib::Compat::Bool $udlc, |
51 |
| - $udlc_stratum, |
52 |
| - Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $ntpsigndsocket, |
53 |
| - Variant[Any, Undef, Stdlib::Compat::String] $authprov, |
| 29 | + Variant[Array[String], Stdlib::Compat::Array] $peers, |
| 30 | + Variant[Array[String], Stdlib::Compat::Array] $preferred_servers, |
| 31 | + Variant[Array[String], Stdlib::Compat::Array] $restrict, |
| 32 | + Variant[Array[String], Stdlib::Compat::Array] $interfaces, |
| 33 | + Variant[Array[String], Any] $interfaces_ignore, |
| 34 | + Variant[Array[String], Stdlib::Compat::Array] $servers, |
| 35 | + Variant[Boolean, Stdlib::Compat::Bool] $service_enable, |
| 36 | + Variant[String, Stdlib::Compat::String] $service_ensure, |
| 37 | + Variant[Boolean, Stdlib::Compat::Bool] $service_manage, |
| 38 | + Variant[String, Stdlib::Compat::String] $service_name, |
| 39 | + Variant[String, Any] $service_provider, |
| 40 | + Variant[Optional[Integer[0, 65535]], Boolean, Undef, Stdlib::Compat::Numeric] $stepout, |
| 41 | + Variant[Optional[Tea::Absolutepath], Boolean, Undef, Stdlib::Compat::String] $step_tickers_file, |
| 42 | + Variant[Optional[String], Any, Undef, Stdlib::Compat::String] $step_tickers_template, |
| 43 | + Variant[Boolean, Stdlib::Compat::Bool] $tinker = $ntp::params::tinker, |
| 44 | + Variant[Boolean, Stdlib::Compat::Bool] $tos, |
| 45 | + Variant[Optional[Integer[1]], Boolean, Undef, Stdlib::Compat::Numeric] $tos_minclock, |
| 46 | + Variant[Optional[Integer[1]], Boolean, Undef, Stdlib::Compat::Numeric] $tos_minsane, |
| 47 | + Variant[Optional[Integer[1]], Boolean, Undef, Stdlib::Compat::Numeric] $tos_floor, |
| 48 | + Variant[Optional[Integer[1]], Boolean, Undef, Stdlib::Compat::Numeric] $tos_ceiling, |
| 49 | + Variant[Variant[Boolean, Integer[0,1]], Boolean, Undef, Pattern['^[0|1]$']] $tos_cohort, |
| 50 | + Variant[Boolean, Stdlib::Compat::Bool] $udlc, |
| 51 | + Variant[Optional[Integer[1,15]], Any] $udlc_stratum, |
| 52 | + Variant[Optional[Tea::Absolutepath], Boolean, Undef, Stdlib::Compat::Absolute_path] $ntpsigndsocket, |
| 53 | + Variant[Optional[String], Any, Undef, Stdlib::Compat::String] $authprov, |
54 | 54 | ) inherits ntp::params {
|
55 | 55 |
|
56 |
| - validate_bool($broadcastclient) |
57 |
| - validate_absolute_path($config) |
58 |
| - validate_string($config_template) |
59 |
| - validate_bool($disable_auth) |
60 |
| - validate_bool($disable_dhclient) |
61 |
| - validate_bool($disable_kernel) |
62 |
| - validate_bool($disable_monitor) |
63 |
| - validate_absolute_path($driftfile) |
64 |
| - if $logfile { validate_absolute_path($logfile) } |
65 |
| - if $ntpsigndsocket { validate_absolute_path($ntpsigndsocket) } |
66 |
| - if $leapfile { validate_absolute_path($leapfile) } |
67 |
| - validate_bool($iburst_enable) |
68 |
| - validate_array($keys) |
69 |
| - validate_bool($keys_enable) |
70 |
| - validate_re($keys_controlkey, ['^\d+$', '']) |
71 |
| - validate_re($keys_requestkey, ['^\d+$', '']) |
72 |
| - validate_array($keys_trusted) |
73 |
| - if $minpoll { validate_numeric($minpoll, 16, 3) } |
74 |
| - if $maxpoll { validate_numeric($maxpoll, 16, 3) } |
75 |
| - validate_string($package_ensure) |
76 |
| - validate_bool($package_manage) |
77 |
| - validate_array($package_name) |
78 |
| - if $panic { validate_numeric($panic, 65535, 0) } |
79 |
| - validate_array($preferred_servers) |
80 |
| - validate_array($restrict) |
81 |
| - validate_array($interfaces) |
82 |
| - validate_array($servers) |
83 |
| - validate_array($fudge) |
84 |
| - validate_bool($service_enable) |
85 |
| - validate_string($service_ensure) |
86 |
| - validate_bool($service_manage) |
87 |
| - validate_string($service_name) |
88 |
| - if $stepout { validate_numeric($stepout, 65535, 0) } |
| 56 | + validate_legacy(Boolean, 'bool', $broadcastclient) |
| 57 | + validate_legacy(Tea::Absolutepath, 'absolute_path', $config) |
| 58 | + |
| 59 | + assert_type(String, $config_file_mode) |$expected, $actual| { |
| 60 | + deprecation("ntp::config_file_mode should be '${expected}', not '${actual}'") |
| 61 | + } |
| 62 | + |
| 63 | + validate_legacy(String[1], 'string', $config_template) |
| 64 | + validate_legacy(Boolean, 'bool', $disable_auth) |
| 65 | + validate_legacy(Boolean, 'bool', $disable_dhclient) |
| 66 | + validate_legacy(Boolean, 'bool', $disable_kernel) |
| 67 | + validate_legacy(Boolean, 'bool', $disable_monitor) |
| 68 | + validate_legacy(Tea::Absolutepath, 'absolute_path', $driftfile) |
| 69 | + |
| 70 | + if $logfile { validate_legacy(Optional[Tea::Absolutepath], 'absolute_path', $logfile) } |
| 71 | + elsif $logfile == undef { } |
| 72 | + else { deprecation('ntp::logfile is false, but should be undef') } |
| 73 | + |
| 74 | + if $ntpsigndsocket { validate_legacy(Optional[Tea::Absolutepath], 'absolute_path', $ntpsigndsocket) } |
| 75 | + elsif $ntpsigndsocket == undef { } |
| 76 | + else { deprecation('ntp::ntpsigndsocket is false, but should be undef') } |
| 77 | + |
| 78 | + if $leapfile { validate_legacy(Optional[Tea::Absolutepath], 'absolute_path', $leapfile) } |
| 79 | + elsif $leapfile == undef { } |
| 80 | + else { deprecation('ntp::leapfile is false, but should be undef') } |
| 81 | + |
| 82 | + validate_legacy(Boolean, 'bool', $iburst_enable) |
| 83 | + validate_legacy(Array[String], 'array', $keys) |
| 84 | + validate_legacy(Boolean, 'bool', $keys_enable) |
| 85 | + validate_legacy(Optional[Ntp::Key_id], 're', $keys_controlkey, ['^\d+$', '']) |
| 86 | + validate_legacy(Optional[Ntp::Key_id], 're', $keys_requestkey, ['^\d+$', '']) |
| 87 | + validate_legacy(Optional[Array[Ntp::Key_id]], 'array', $keys_trusted) |
| 88 | + if $minpoll { validate_legacy(Optional[Ntp::Poll_interval], 'numeric', $minpoll, 16, 3) } |
| 89 | + elsif $minpoll == undef { } |
| 90 | + else { deprecation('ntp::minpoll is false, but should be undef') } |
| 91 | + |
| 92 | + if $maxpoll { validate_legacy(Optional[Ntp::Poll_interval], 'numeric', $maxpoll, 16, 3) } |
| 93 | + elsif $maxpoll == undef { } |
| 94 | + else { deprecation('ntp::maxpoll is false, but should be undef') } |
| 95 | + |
| 96 | + validate_legacy(String, 'string', $package_ensure) |
| 97 | + validate_legacy(Boolean, 'bool', $package_manage) |
| 98 | + validate_legacy(Array[String], 'array', $package_name) |
| 99 | + if $panic { validate_legacy(Optional[Integer[0]], 'numeric', $panic, 65535, 0) } |
| 100 | + elsif $panic == undef { } |
| 101 | + else { deprecation('ntp::panic is false, but should be undef') } |
| 102 | + |
| 103 | + validate_legacy(Array[String], 'array', $preferred_servers) |
| 104 | + validate_legacy(Array[String], 'array', $restrict) |
| 105 | + validate_legacy(Array[String], 'array', $interfaces) |
| 106 | + assert_type(Array[String], $interfaces_ignore) |$expected, $actual| { |
| 107 | + deprecation("ntp::interfaces_ignore should be '${expected}', not '${actual}'") |
| 108 | + } |
| 109 | + validate_legacy(Array[String], 'array', $servers) |
| 110 | + validate_legacy(Array[String], 'array', $fudge) |
| 111 | + validate_legacy(Boolean, 'bool', $service_enable) |
| 112 | + validate_legacy(String, 'string', $service_ensure) |
| 113 | + validate_legacy(Boolean, 'bool', $service_manage) |
| 114 | + validate_legacy(String, 'string', $service_name) |
| 115 | + assert_type(String, $service_provider) |$expected, $actual| { |
| 116 | + deprecation("ntp::service_provider should be '${expected}', not '${actual}'") |
| 117 | + } |
| 118 | + |
| 119 | + if $stepout { validate_legacy(Optional[Integer[0, 65535]], 'numeric', $stepout, 65535, 0) } |
| 120 | + elsif $stepout == undef { } |
| 121 | + else { deprecation('ntp::stepout is false, but should be undef') } |
| 122 | + |
89 | 123 | if $step_tickers_file {
|
90 |
| - validate_string($step_tickers_file) |
91 |
| - validate_string($step_tickers_template) |
| 124 | + validate_legacy(Optional[Tea::Absolutepath], 'string', $step_tickers_file) |
| 125 | + validate_legacy(Optional[String], 'string', $step_tickers_template) |
92 | 126 | }
|
93 |
| - validate_bool($tinker) |
94 |
| - validate_bool($tos) |
95 |
| - if $tos_minclock { validate_numeric($tos_minclock) } |
96 |
| - if $tos_minsane { validate_numeric($tos_minsane) } |
97 |
| - if $tos_floor { validate_numeric($tos_floor) } |
98 |
| - if $tos_ceiling { validate_numeric($tos_ceiling) } |
99 |
| - if $tos_cohort { validate_re($tos_cohort, '^[0|1]$', "Must be 0 or 1, got: ${tos_cohort}") } |
100 |
| - validate_bool($udlc) |
101 |
| - validate_array($peers) |
102 |
| - if $authprov { validate_string($authprov) } |
103 |
| - |
104 |
| - if $config_dir { |
105 |
| - validate_absolute_path($config_dir) |
| 127 | + elsif $step_tickers_file == undef { } |
| 128 | + else { deprecation('ntp::step_tickers_file is false, but should be undef') } |
| 129 | + |
| 130 | + # In cases where $step_tickers_file evaluated to false, anything could have been |
| 131 | + # passed to $step_tickers_template. This deprecation removes that hole. |
| 132 | + assert_type(Optional[String], $step_tickers_template) |$expected, $actual| { |
| 133 | + deprecation("ntp::step_tickers_template should be '${expected}', not '${actual}'") |
| 134 | + } |
| 135 | + |
| 136 | + validate_legacy(Boolean, 'bool', $tinker) |
| 137 | + validate_legacy(Boolean, 'bool', $tos) |
| 138 | + if $tos_minclock { validate_legacy(Optional[Integer[1]], 'numeric', $tos_minclock) } |
| 139 | + elsif $tos_minclock == undef { } |
| 140 | + else { deprecation('ntp::tos_minclock is false, but should be undef') } |
| 141 | + |
| 142 | + if $tos_minsane { validate_legacy(Optional[Integer[1]], 'numeric', $tos_minsane) } |
| 143 | + elsif $tos_minsane == undef { } |
| 144 | + else { deprecation('ntp::tos_minsane is false, but should be undef') } |
| 145 | + |
| 146 | + if $tos_floor { validate_legacy(Optional[Integer[1]], 'numeric', $tos_floor) } |
| 147 | + elsif $tos_floor == undef { } |
| 148 | + else { deprecation('ntp::tos_floor is false, but should be undef') } |
| 149 | + |
| 150 | + if $tos_ceiling { validate_legacy(Optional[Integer[1]], 'numeric', $tos_ceiling) } |
| 151 | + elsif $tos_ceiling == undef { } |
| 152 | + else { deprecation('ntp::tos_ceiling is false, but should be undef') } |
| 153 | + |
| 154 | + if $tos_cohort { validate_legacy(Variant[Boolean, Integer[0,1]], 're', $tos_cohort, '^[0|1]$', "Must be 0 or 1, got: ${tos_cohort}") } |
| 155 | + elsif $tos_cohort == undef { } |
| 156 | + elsif $tos_cohort == false { } |
| 157 | + else { |
| 158 | + # No idea what else could come through here, but better safe than sorry, and |
| 159 | + # with the next major release, this will go away, anyways. |
| 160 | + assert_type(Optional[Variant[Boolean, Integer[0,1]]], $tos_cohort) |$expected, $actual| { |
| 161 | + deprecation("ntp::tos_cohort should be '${expected}', not '${actual}'") |
| 162 | + } |
106 | 163 | }
|
107 | 164 |
|
| 165 | + validate_legacy(Boolean, 'bool', $udlc) |
| 166 | + assert_type(Optional[Integer[1,15]], $udlc_stratum) |$expected, $actual| { |
| 167 | + deprecation("ntp::udlc_stratum should be '${expected}', not '${actual}'") |
| 168 | + } |
| 169 | + |
| 170 | + validate_legacy(Array[String], 'array', $peers) |
| 171 | + if $authprov { validate_legacy(Optional[String], 'string', $authprov) } |
| 172 | + elsif $authprov == undef { } |
| 173 | + else { deprecation('ntp::authprov is false, but should be undef') } |
| 174 | + |
| 175 | + |
| 176 | + if $config_dir { validate_legacy(Optional[Tea::Absolutepath], 'absolute_path', $config_dir) } |
| 177 | + elsif $config_dir == undef { } |
| 178 | + else { deprecation('ntp::config_dir is false, but should be undef') } |
| 179 | + |
| 180 | + |
108 | 181 | if $autoupdate {
|
109 |
| - notice('ntp: autoupdate parameter has been deprecated and replaced with package_ensure. Set package_ensure to latest for the same behavior as autoupdate => true.') |
| 182 | + notice('ntp: autoupdate parameter has been deprecation and replaced with package_ensure. Set package_ensure to latest for the same behavior as autoupdate => true.') |
110 | 183 | }
|
111 | 184 |
|
112 | 185 | # Anchor this as per #8040 - this ensures that classes won't float off and
|
|
0 commit comments