mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 11:24:50 +00:00
Fix creation of privilege with permissions.
Module was raising exceptions when trying to create a new privilege
with permissions. This change fixes the behavior and ensuure
idempotence with trying to create a privilege with the same values.
Tests for this behavior have been appended to:
tests/privilege/test_privilege.yml
This commit is contained in:
@@ -234,14 +234,22 @@ def main():
|
|||||||
if action == "privilege":
|
if action == "privilege":
|
||||||
# Found the privilege
|
# Found the privilege
|
||||||
if res_find is not None:
|
if res_find is not None:
|
||||||
|
res_cmp = {
|
||||||
|
k: v for k, v in res_find.items()
|
||||||
|
if k not in [
|
||||||
|
"objectclass", "cn", "dn",
|
||||||
|
"memberof_permisssion"
|
||||||
|
]
|
||||||
|
}
|
||||||
# For all settings is args, check if there are
|
# For all settings is args, check if there are
|
||||||
# different settings in the find result.
|
# different settings in the find result.
|
||||||
# If yes: modify
|
# If yes: modify
|
||||||
if not compare_args_ipa(ansible_module, args,
|
if args and not compare_args_ipa(ansible_module, args,
|
||||||
res_find):
|
res_cmp):
|
||||||
commands.append([name, "privilege_mod", args])
|
commands.append([name, "privilege_mod", args])
|
||||||
else:
|
else:
|
||||||
commands.append([name, "privilege_add", args])
|
commands.append([name, "privilege_add", args])
|
||||||
|
res_find = {}
|
||||||
|
|
||||||
member_args = {}
|
member_args = {}
|
||||||
if permission:
|
if permission:
|
||||||
|
|||||||
@@ -140,6 +140,30 @@
|
|||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
|
|
||||||
|
- name: Ensure "Broad Privilege" is absent.
|
||||||
|
ipaprivilege:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: Broad Privilege
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure privilege Broad Privilege is created with permission. (issue 529)
|
||||||
|
ipaprivilege:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: Broad Privilege
|
||||||
|
permission:
|
||||||
|
- "Write IPA Configuration"
|
||||||
|
register: result
|
||||||
|
failed_when: not result.changed or result.failed
|
||||||
|
|
||||||
|
- name: Ensure privilege Broad Privilege is created with permission, again. (issue 529)
|
||||||
|
ipaprivilege:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: Broad Privilege
|
||||||
|
permission:
|
||||||
|
- "Write IPA Configuration"
|
||||||
|
register: result
|
||||||
|
failed_when: result.changed or result.failed
|
||||||
|
|
||||||
# CLEANUP TEST ITEMS
|
# CLEANUP TEST ITEMS
|
||||||
|
|
||||||
- name: Ensure privilege testing privileges are absent
|
- name: Ensure privilege testing privileges are absent
|
||||||
|
|||||||
Reference in New Issue
Block a user