Skip to content

Commit 1515af2

Browse files
committed
(FM-5361) Remove all the legacy/backwards-compat/deprecation logic
This finishes the move to a cleaner puppet4 interface. Since this is a breaking change, it also bumps the major version. Users of the previous version who were running without receiving any deprecation warnings can use this version without any changes.
1 parent 0b526e0 commit 1515af2

File tree

6 files changed

+68
-216
lines changed

6 files changed

+68
-216
lines changed

README.markdown

+3-7
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ class { '::ntp':
131131

132132
The following parameters are available in the `::ntp` class:
133133

134-
####`autoupdate`
135-
136-
**Deprecated; replaced by the `package_ensure` parameter**. Tells Puppet whether to keep the ntp module updated to the latest version available. Valid options: true or false. Default value: false
137-
138134
####`broadcastclient`
139135

140136
Enable reception of broadcast server messages to any local interface.
@@ -158,7 +154,7 @@ Specifies a file to act as a template for the config file. Valid options: string
158154

159155
####`disable_auth`
160156

161-
Do not require cryptographic authentication for broadcast client, multicast
157+
Do not require cryptographic authentication for broadcast client, multicast
162158
client and symmetric passive associations.
163159

164160
####`disable_auth`
@@ -235,10 +231,10 @@ Tells Puppet to use non-standard maximal poll interval of upstream servers. Vali
235231
####`ntpsigndsocket`
236232

237233
Tells NTP to sign packets using the socket in the ntpsigndsocket path. NTP must be configured to sign sockets for this to work.
238-
Valid option: a path to the socket directory; for example, for Samba it would be:
234+
Valid option: a path to the socket directory; for example, for Samba it would be:
239235

240236
~~~~
241-
ntpsigndsocket = usr/local/samba/var/lib/ntp_signd/
237+
ntpsigndsocket = usr/local/samba/var/lib/ntp_signd/
242238
~~~~
243239

244240
Default value: undef.

data/common.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
ntp::authprov: ~
3-
ntp::autoupdate: false
43
ntp::broadcastclient: false
54
ntp::config_dir: ~
65
ntp::config_file_mode: '0644'

manifests/init.pp

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

190-
validate_legacy(Boolean, 'validate_bool', $_tinker)
191-
if $_panic { validate_legacy(Optional[Integer[0]], 'validate_numeric', $_panic, 65535, 0) }
192-
elsif $_panic == undef { }
193-
else { deprecation('puppet_3_type_check', 'ntp::panic is false, but should be undef') }
194-
19563
# Anchor this as per #8040 - this ensures that classes won't float off and
19664
# mess everything up. You can read about this at:
19765
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
@@ -200,5 +68,4 @@
20068
class { '::ntp::config': } ~>
20169
class { '::ntp::service': } ->
20270
anchor { 'ntp::end': }
203-
20471
}

metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "puppetlabs-ntp",
3-
"version": "5.0.0",
3+
"version": "6.0.0",
44
"author": "Puppet Labs",
55
"summary": "Installs, configures, and manages the NTP service.",
66
"license": "Apache-2.0",

spec/acceptance/ntp_parameters_spec.rb

+3-13
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@
5959
end
6060
end
6161

62-
describe 'autoupdate' do
63-
it 'raises a deprecation warning' do
64-
pp = "class { 'ntp': autoupdate => true }"
65-
66-
apply_manifest(pp, :catch_failures => true) do |r|
67-
expect(r.stderr).to match(/autoupdate parameter has been deprecated and replaced with package_ensure/)
68-
end
69-
end
70-
end
71-
7262
describe 'config' do
7363
it 'sets the ntp.conf location' do
7464
pp = "class { 'ntp': config => '/etc/antp.conf' }"
@@ -115,9 +105,9 @@
115105
pp = <<-EOS
116106
class { 'ntp':
117107
keys_enable => true,
118-
keys_controlkey => '15',
119-
keys_requestkey => '1',
120-
keys_trusted => [ '1', '2' ],
108+
keys_controlkey => 15,
109+
keys_requestkey => 1,
110+
keys_trusted => [ 1, 2 ],
121111
keys => [ '1 M AAAABBBB' ],
122112
}
123113
EOS

spec/classes/ntp_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
context "when enabled" do
4242
let(:params) {{
4343
:keys_enable => true,
44-
:keys_trusted => ['1', '2', '3'],
45-
:keys_controlkey => '2',
46-
:keys_requestkey => '3',
44+
:keys_trusted => [1, 2, 3],
45+
:keys_controlkey => 2,
46+
:keys_requestkey => 3,
4747
}}
4848

4949
it { should contain_file('/etc/ntp.conf').with({
@@ -61,9 +61,9 @@
6161
context "when disabled" do
6262
let(:params) {{
6363
:keys_enable => false,
64-
:keys_trusted => ['1', '2', '3'],
65-
:keys_controlkey => '2',
66-
:keys_requestkey => '3',
64+
:keys_trusted => [1, 2, 3],
65+
:keys_controlkey => 2,
66+
:keys_requestkey => 3,
6767
}}
6868

6969
it { should_not contain_file('/etc/ntp.conf').with({
@@ -571,12 +571,12 @@
571571
describe 'with parameters minpoll or maxpoll changed from default' do
572572
context 'when minpoll changed from default' do
573573
let(:params) {{
574-
:minpoll => 3,
574+
:minpoll => 6,
575575
}}
576576

577577
it do
578578
should contain_file('/etc/ntp.conf').with({
579-
'content' => /minpoll 3/,
579+
'content' => /minpoll 6/,
580580
})
581581
end
582582
end
@@ -595,13 +595,13 @@
595595

596596
context 'when minpoll and maxpoll changed from default simultaneously' do
597597
let(:params) {{
598-
:minpoll => 3,
598+
:minpoll => 6,
599599
:maxpoll => 12,
600600
}}
601601

602602
it do
603603
should contain_file('/etc/ntp.conf').with({
604-
'content' => /minpoll 3 maxpoll 12\n/,
604+
'content' => /minpoll 6 maxpoll 12\n/,
605605
})
606606
end
607607
end

0 commit comments

Comments
 (0)