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:
Thomas Woerner
2022-02-14 17:57:04 +01:00
parent 892cb037eb
commit 8010d19be9
5 changed files with 50 additions and 10 deletions

View File

@@ -221,9 +221,9 @@ def main():
# Normalize principals
if principal:
principal = servicedelegation_normalize_principals(ansible_module,
principal)
if target:
principal = servicedelegation_normalize_principals(
ansible_module, principal, state == "present")
if target and state == "present":
check_targets(ansible_module, target)
commands = []

View File

@@ -177,8 +177,8 @@ def main():
# Normalize principals
if principal:
principal = servicedelegation_normalize_principals(ansible_module,
principal)
principal = servicedelegation_normalize_principals(
ansible_module, principal, state == "present")
commands = []
principal_add = principal_del = []