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/4420/head
Christian Kotte 2018-08-27 21:13:35 +02:00 committed by Brian Coca
parent 4dea9d84ed
commit fc64ce3e0c
1 changed files with 3 additions and 1 deletions

View File

@ -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