summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai <kai.scorpio@gmail.com>2017-04-25 00:53:12 +0100
committerBrian Coca <brian.coca+git@gmail.com>2017-04-24 19:54:50 -0400
commit58666c0ca4209952252a5e20145d4e310ba4ccf7 (patch)
tree8c3ada20301439d238c8b4067d600ff754654f64
parent476e8c71363ec81f98a2b6f0ae53039c15ebbd04 (diff)
downloadansible-58666c0ca4209952252a5e20145d4e310ba4ccf7.tar.gz
Fix systemd in chroot (#23904)
* Fix systemd in chroot The 'request ignored' message is in stderr, not stdout. * Check both stdout and stderr for systemd message Some versions of systemd report to stderr, others to stdout. Also check whether output could be a valid normal response to avoid false positives. (cherry picked from commit cb13aea88b2511806ed28ef08ca447751a14c792)
-rw-r--r--lib/ansible/modules/system/systemd.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py
index 2e7d0e6739..94cede102a 100644
--- a/lib/ansible/modules/system/systemd.py
+++ b/lib/ansible/modules/system/systemd.py
@@ -252,6 +252,9 @@ from ansible.module_utils._text import to_native
def is_running_service(service_status):
return service_status['ActiveState'] in set(['active', 'activating'])
+def request_was_ignored(out):
+ return '=' not in out and 'ignoring request' in out
+
# ===========================================
# Main control flow
@@ -299,7 +302,7 @@ def main():
# check service data, cannot error out on rc as it changes across versions, assume not found
(rc, out, err) = module.run_command("%s show '%s'" % (systemctl, unit))
- if out.find('ignoring request') != -1:
+ if request_was_ignored(out) or request_was_ignored(err):
# fallback list-unit-files as show does not work on some systems (chroot)
# not used as primary as it skips some services (like those using init.d) and requires .service/etc notation
(rc, out, err) = module.run_command("%s list-unit-files '%s'" % (systemctl, unit))