mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-28 18:34:44 +00:00
servicedelegation: Do not fail for not existing members with state absent
Ensuring absence of members (services and targets) that do not exist may not fail as they are not members for servicedelegationtarget and servicedelegationrule. servicedelegation_normalize_principals in ansible_freeipa_module has been extended with a check_exists argument that defaults to False. state == "present" is now given as this argument to turn on the element exists check only if elements should be added.
This commit is contained in:
@@ -551,7 +551,8 @@ else:
|
||||
return False
|
||||
return True
|
||||
|
||||
def servicedelegation_normalize_principals(module, principal):
|
||||
def servicedelegation_normalize_principals(module, principal,
|
||||
check_exists=False):
|
||||
"""
|
||||
Normalize servicedelegation principals.
|
||||
|
||||
@@ -620,12 +621,13 @@ else:
|
||||
_host = _host[:-len(realm) - 1]
|
||||
|
||||
# Seach for host
|
||||
if not _check_exists(module, "host", _host):
|
||||
if check_exists and not _check_exists(module, "host", _host):
|
||||
module.fail_json(msg="Host '%s' does not exist" % _host)
|
||||
|
||||
# Check the service principal exists
|
||||
else:
|
||||
if not _check_exists(module, "service", princ):
|
||||
if check_exists and \
|
||||
not _check_exists(module, "service", princ):
|
||||
module.fail_json(msg="Service %s does not exist" % princ)
|
||||
|
||||
_principal.append(princ)
|
||||
|
||||
Reference in New Issue
Block a user