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
pull/44733/head
Christian Kotte 6 years ago committed by Brian Coca
parent 4dea9d84ed
commit fc64ce3e0c

@ -366,8 +366,10 @@ def main():
is_systemd = 'LoadState' in result['status'] and result['status']['LoadState'] != 'not-found' 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 # 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'])) module.fail_json(msg="Error loading unit file '%s': %s" % (unit, result['status']['LoadError']))
else: else:
# Check for systemctl command # Check for systemctl command

Loading…
Cancel
Save