From 19496b5b7395085ac068dfd071ec6773b471d1fa Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 13 Jan 2017 16:29:29 -0500 Subject: [PATCH] fix service status setting fixes #18687 as 'disabled' can be at the end of the output fixes #20228 by not falling back to init scripts when it is a user service --- lib/ansible/modules/system/systemd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py index 773f14ec249..caa578dc7f9 100644 --- a/lib/ansible/modules/system/systemd.py +++ b/lib/ansible/modules/system/systemd.py @@ -370,8 +370,11 @@ def main(): if rc == 0: enabled = True elif rc == 1: - # if both init script and unit file exist stdout should have enabled/disabled, otherwise use rc entries - if is_initd and (not out.startswith('disabled') or sysv_is_enabled(unit)): + # if not a user service and both init script and unit file exist stdout should have enabled/disabled, otherwise use rc entries + if not module.params['user'] and \ + is_initd and \ + (not out.strip().endswith('disabled') or sysv_is_enabled(unit)): + enabled = True # default to current state