From fc64ce3e0c82ea8399f939478772df3e9fdfc953 Mon Sep 17 00:00:00 2001 From: Christian Kotte Date: Mon, 27 Aug 2018 21:13:35 +0200 Subject: [PATCH] Fix systemd service is already masked issue (#44730) * Check if service is already masked Newer versions of Systemd now report a 'LoadError' when the unit file is masked. This causes the play to fail with an error stating that the service is already masked. Now the systemd module checks if the service is masked and doesn't fail if it's masked and LoadError is reported. Fixes issue #42384. * Remove useless parens --- lib/ansible/modules/system/systemd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py index b1c54d1137..5ddc881f8e 100644 --- a/lib/ansible/modules/system/systemd.py +++ b/lib/ansible/modules/system/systemd.py @@ -366,8 +366,10 @@ def main(): is_systemd = 'LoadState' in result['status'] and result['status']['LoadState'] != 'not-found' + is_masked = 'LoadState' in result['status'] and result['status']['LoadState'] == 'masked' + # Check for loading error - if is_systemd and 'LoadError' in result['status']: + if is_systemd and not is_masked and 'LoadError' in result['status']: module.fail_json(msg="Error loading unit file '%s': %s" % (unit, result['status']['LoadError'])) else: # Check for systemctl command