Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix systemd in chroot #23904

Merged
merged 2 commits into from
Apr 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/ansible/modules/system/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
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
Expand Down Expand Up @@ -307,7 +310,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))
Expand Down