summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/system/systemd.py
diff options
context:
space:
mode:
authorVlad Mencl <vladimir.mencl@reannz.co.nz>2018-09-29 04:05:48 +1200
committerBrian Coca <bcoca@users.noreply.github.com>2018-09-28 12:05:48 -0400
commitef131c7556703915632fbcb4bfbf845758e0dac9 (patch)
treeeb06ed568937fe4da54a1841f449bd5f6608f1a6 /lib/ansible/modules/system/systemd.py
parentdae217204557446d4f7a1456b6fe7978ae5c3153 (diff)
downloadansible-ef131c7556703915632fbcb4bfbf845758e0dac9.tar.gz
module/systemd: fix logic determining if a service needs to be enabled (#46245)
* modules/systemd: fix logic: allow scope to default to 'system' Fix logic introduced in 7ea909418e5: if 'scope' param is not specified, it defaults to system, but the value of module.params['scope'] is None, not 'system' - so allow for that. * modules/systemd: fix logic: disabled means disabled Fix logic determining whether a service with both systemd and initd files is enabled or disabled. In situations where systemd thinks service is disabled, but rc.d symlinks mark it as enabled, this module wrongly assumes the service is enabled. Fix this logic: disabled means disabled Only when the output from does NOT include disabled, consider the status of rc.d symlinks. This essentially replicates the fixes done to the systemd handling in the "service" module in 3c89a21e0c0 Fixes #22303 Fixes #44409
Diffstat (limited to 'lib/ansible/modules/system/systemd.py')
-rw-r--r--lib/ansible/modules/system/systemd.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py
index 47583ad1c4..fca6714f74 100644
--- a/lib/ansible/modules/system/systemd.py
+++ b/lib/ansible/modules/system/systemd.py
@@ -443,10 +443,11 @@ 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'] == 'system' and \
+ if module.params['scope'] in (None, 'system') and \
not module.params['user'] and \
is_initd and \
- (not out.strip().endswith('disabled') or sysv_is_enabled(unit)):
+ not out.strip().endswith('disabled') and \
+ sysv_is_enabled(unit):
enabled = True
# default to current state