systemd: set scope default to "system" (#67006)

- Make "system" default scope for systemd
- Remove extra None checks since there is now a default
This commit is contained in:
Ted Pearson 2020-05-14 11:36:47 -04:00 committed by GitHub
parent cedfe34619
commit c13b040e67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- systemd - default scope is now explicitly "system"

View file

@ -72,6 +72,7 @@ options:
The user dbus process is normally started during normal login, but not during the run of Ansible tasks.
Otherwise you will probably get a 'Failed to connect to bus: no such file or directory' error."
choices: [ system, user, global ]
default: system
version_added: "2.7"
no_block:
description:
@ -332,7 +333,7 @@ def main():
daemon_reload=dict(type='bool', default=False, aliases=['daemon-reload']),
daemon_reexec=dict(type='bool', default=False, aliases=['daemon-reexec']),
user=dict(type='bool'),
scope=dict(type='str', choices=['system', 'user', 'global']),
scope=dict(type='str', default='system', choices=['system', 'user', 'global']),
no_block=dict(type='bool', default=False),
),
supports_check_mode=True,
@ -367,7 +368,7 @@ def main():
# if scope is 'system' or None, we can ignore as there is no extra switch.
# The other choices match the corresponding switch
if module.params['scope'] not in (None, 'system'):
if module.params['scope'] != 'system':
systemctl += " --%s" % module.params['scope']
if module.params['no_block']:
@ -487,7 +488,7 @@ def main():
enabled = True
elif rc == 1:
# if not a user or global user service and both init script and unit file exist stdout should have enabled/disabled, otherwise use rc entries
if module.params['scope'] in (None, 'system') and \
if module.params['scope'] == 'system' and \
not module.params['user'] and \
is_initd and \
not out.strip().endswith('disabled') and \