Fixes service disable when service has no certificates attached.

Services without certificates, but with keytabs were not being
disabled. This change allows execution of service_disable if
there is a certificate or if has_keytab is true.

A new test was added to verify the issue:

    tests/service/test_service_disable.yml
This commit is contained in:
Rafael Guterres Jeffman
2020-06-25 16:26:30 -03:00
parent a6a95e7649
commit e57e4908f9
2 changed files with 73 additions and 3 deletions

View File

@@ -812,9 +812,11 @@ def main():
elif state == "disabled":
if action == "service":
if res_find is not None and \
len(res_find.get('usercertificate', [])) > 0:
commands.append([name, 'service_disable', {}])
if res_find is not None:
has_cert = bool(res_find.get('usercertificate'))
has_keytab = res_find.get('has_keytab', False)
if has_cert or has_keytab:
commands.append([name, 'service_disable', {}])
else:
ansible_module.fail_json(
msg="Invalid action '%s' for state '%s'" %