Skip to content

Commit 6bd493e

Browse files
(maint) Merge up 2098009 to main
Generated by CI * commit '209800967a1e2b80f0b3244e213d42ac1539d28b': (Docs)(maint) Adjust man page line wrapping (PUP-11034) Allow systemd static services to be masked
2 parents 69eb68d + 2098009 commit 6bd493e

File tree

7 files changed

+57
-19
lines changed

7 files changed

+57
-19
lines changed

lib/puppet/application/agent.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ def help
133133
'test', 'tags' and 'fingerprint' are useful.
134134
135135
'--test' runs once in the foreground with verbose logging, then exits.
136-
It also exits if it can't get a valid catalog. `--test` includes the '--detailed-exitcodes' option by default and exits with one of the following exit codes:
136+
It also exits if it can't get a valid catalog. `--test` includes the
137+
'--detailed-exitcodes' option by default and exits with one of the following
138+
exit codes:
137139
138-
* 0: The run succeeded with no changes or failures; the system was already in the desired state.
140+
* 0: The run succeeded with no changes or failures; the system was already in
141+
the desired state.
139142
* 1: The run failed, or wasn't attempted due to another run already in progress.
140143
* 2: The run succeeded, and some resources were changed.
141144
* 4: The run succeeded, and some resources failed.
@@ -246,7 +249,9 @@ def help
246249
'puppet agent' exits after executing this.
247250
248251
* --evaltrace:
249-
Logs each resource as it is being evaluated. This allows you to interactively see exactly what is being done. (This is a Puppet setting, and can go in puppet.conf. Note the special 'no-' prefix for boolean settings on the command line.)
252+
Logs each resource as it is being evaluated. This allows you to interactively
253+
see exactly what is being done. (This is a Puppet setting, and can go in
254+
puppet.conf. Note the special 'no-' prefix for boolean settings on the command line.)
250255
251256
* --fingerprint:
252257
Display the current certificate or certificate signing request
@@ -267,7 +272,8 @@ def help
267272
service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
268273
file. If debugging or verbosity is enabled, this defaults to 'console'.
269274
Otherwise, it defaults to 'syslog' on POSIX systems and 'eventlog' on Windows.
270-
Multiple destinations can be set using a comma separated list (eg: `/path/file1,console,/path/file2`)"
275+
Multiple destinations can be set using a comma separated list
276+
(eg: `/path/file1,console,/path/file2`)"
271277
272278
A path ending with '.json' will receive structured output in JSON format. The
273279
log file will not have an ending ']' automatically written to it due to the
@@ -310,7 +316,8 @@ def help
310316
'no-splay', and 'show_diff'.
311317
312318
* --trace
313-
Prints stack traces on some errors. (This is a Puppet setting, and can go in puppet.conf. Note the special 'no-' prefix for boolean settings on the command line.)
319+
Prints stack traces on some errors. (This is a Puppet setting, and can go in
320+
puppet.conf. Note the special 'no-' prefix for boolean settings on the command line.)
314321
315322
* --verbose:
316323
Turn on verbose reporting.

lib/puppet/application/apply.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def help
113113
Where to send log messages. Choose between 'syslog' (the POSIX syslog
114114
service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
115115
file. Defaults to 'console'.
116-
Multiple destinations can be set using a comma separated list (eg: `/path/file1,console,/path/file2`)"
116+
Multiple destinations can be set using a comma separated list
117+
(eg: `/path/file1,console,/path/file2`)"
117118
118119
A path ending with '.json' will receive structured output in JSON format. The
119120
log file will not have an ending ']' automatically written to it due to the

lib/puppet/application/device.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def help
155155
Where to send log messages. Choose between 'syslog' (the POSIX syslog
156156
service), 'console', or the path to a log file. If debugging or verbosity is
157157
enabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.
158-
Multiple destinations can be set using a comma separated list (eg: `/path/file1,console,/path/file2`)"
158+
Multiple destinations can be set using a comma separated list
159+
(eg: `/path/file1,console,/path/file2`)"
159160
160161
A path ending with '.json' will receive structured output in JSON format. The
161162
log file will not have an ending ']' automatically written to it due to the

lib/puppet/application/resource.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def help
101101
Print extra information.
102102
103103
* --to_yaml:
104-
Output found resources in yaml format, suitable to use with Hiera and create_resources.
104+
Output found resources in yaml format, suitable to use with Hiera and
105+
create_resources.
105106
106107
EXAMPLE
107108
-------

lib/puppet/application/script.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def help
7171
Where to send log messages. Choose between 'syslog' (the POSIX syslog
7272
service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
7373
file. Defaults to 'console'.
74-
Multiple destinations can be set using a comma separated list (eg: `/path/file1,console,/path/file2`)"
74+
Multiple destinations can be set using a comma separated list
75+
(eg: `/path/file1,console,/path/file2`)"
7576
7677
A path ending with '.json' will receive structured output in JSON format. The
7778
log file will not have an ending ']' automatically written to it due to the

lib/puppet/provider/service/systemd.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ def self.instances
4545
def enabled_insync?(current)
4646
case cached_enabled?[:output]
4747
when 'static'
48-
Puppet.debug("Unable to enable or disable static service #{@resource[:name]}")
49-
return true
48+
# masking static services is OK, but enabling/disabling them is not
49+
if @resource[:enable] == :mask
50+
current == @resource[:enable]
51+
else
52+
Puppet.debug("Unable to enable or disable static service #{@resource[:name]}")
53+
return true
54+
end
5055
when 'indirect'
5156
Puppet.debug("Service #{@resource[:name]} is in 'indirect' state and cannot be enabled/disabled")
5257
return true

spec/unit/provider/service/systemd_spec.rb

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,39 @@
473473
context 'when service state is static' do
474474
let(:service_state) { 'static' }
475475

476-
it 'is always enabled_insync even if current value is the same as expected' do
477-
expect(provider).to be_enabled_insync(:false)
476+
context 'when enable is not mask' do
477+
it 'is always enabled_insync even if current value is the same as expected' do
478+
expect(provider).to be_enabled_insync(:false)
479+
end
480+
481+
it 'is always enabled_insync even if current value is not the same as expected' do
482+
expect(provider).to be_enabled_insync(:true)
483+
end
484+
485+
it 'logs a debug messsage' do
486+
expect(Puppet).to receive(:debug).with("Unable to enable or disable static service sshd.service")
487+
provider.enabled_insync?(:true)
488+
end
478489
end
479490

480-
it 'is always enabled_insync even if current value is not the same as expected' do
481-
expect(provider).to be_enabled_insync(:true)
482-
end
491+
context 'when enable is mask' do
492+
let(:provider) do
493+
provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service',
494+
:enable => 'mask'))
495+
end
483496

484-
it 'logs a debug messsage' do
485-
expect(Puppet).to receive(:debug).with("Unable to enable or disable static service sshd.service")
486-
provider.enabled_insync?(:true)
497+
it 'is enabled_insync if current value is the same as expected' do
498+
expect(provider).to be_enabled_insync(:mask)
499+
end
500+
501+
it 'is not enabled_insync if current value is not the same as expected' do
502+
expect(provider).not_to be_enabled_insync(:true)
503+
end
504+
505+
it 'logs no debug messsage' do
506+
expect(Puppet).not_to receive(:debug)
507+
provider.enabled_insync?(:true)
508+
end
487509
end
488510
end
489511

0 commit comments

Comments
 (0)