mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 19:34:45 +00:00
hbacrule: Fix use of builtin sudo hbacsvcgroup
hbacsvcgroup names are converted to lower case while creation with hbacsvcgroup_add. The hbacsvcgroup for sudo is builtin with the name "Sudo" though. This breaks the lower case comparison. Therefore all memberservice_hbacsvcgroup items are converted to lower case if "Sudo" is in the list.
This commit is contained in:
@@ -186,7 +186,17 @@ def find_hbacrule(module, name):
|
|||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="There is more than one hbacrule '%s'" % (name))
|
msg="There is more than one hbacrule '%s'" % (name))
|
||||||
elif len(_result["result"]) == 1:
|
elif len(_result["result"]) == 1:
|
||||||
return _result["result"][0]
|
res = _result["result"][0]
|
||||||
|
# hbacsvcgroup names are converted to lower case while creation with
|
||||||
|
# hbacsvcgroup_add.
|
||||||
|
# The hbacsvcgroup for sudo is builtin with the name "Sudo" though.
|
||||||
|
# This breaks the lower case comparison. Therefore all
|
||||||
|
# memberservice_hbacsvcgroup items are converted to lower case if
|
||||||
|
# "Sudo" is in the list.
|
||||||
|
_member = "memberservice_hbacsvcgroup"
|
||||||
|
if _member in res and "Sudo" in res[_member]:
|
||||||
|
res[_member] = [item.lower() for item in res[_member]]
|
||||||
|
return res
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -124,6 +125,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
|
|
||||||
@@ -147,6 +149,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -171,6 +174,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | lower }}"
|
- "{{ hbacsvc_list[1] | lower }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | lower }}"
|
- "{{ hbacsvcgroup_list[0] | lower }}"
|
||||||
|
- sudo
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
|
|
||||||
@@ -194,6 +198,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | upper }}"
|
- "{{ hbacsvc_list[1] | upper }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | upper }}"
|
- "{{ hbacsvcgroup_list[0] | upper }}"
|
||||||
|
- SUDO
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
|
|
||||||
@@ -230,6 +235,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -254,6 +260,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
action: member
|
action: member
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -278,6 +285,7 @@
|
|||||||
- "{{ hbacsvc_list[1] }}"
|
- "{{ hbacsvc_list[1] }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] }}"
|
- "{{ hbacsvcgroup_list[0] }}"
|
||||||
|
- Sudo
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -302,6 +310,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | lower }}"
|
- "{{ hbacsvc_list[1] | lower }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | lower }}"
|
- "{{ hbacsvcgroup_list[0] | lower }}"
|
||||||
|
- sudo
|
||||||
action: member
|
action: member
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -326,6 +335,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | upper }}"
|
- "{{ hbacsvc_list[1] | upper }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | upper }}"
|
- "{{ hbacsvcgroup_list[0] | upper }}"
|
||||||
|
- SUDO
|
||||||
action: member
|
action: member
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -352,6 +362,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | upper }}"
|
- "{{ hbacsvc_list[1] | upper }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | upper }}"
|
- "{{ hbacsvcgroup_list[0] | upper }}"
|
||||||
|
- SUDO
|
||||||
action: member
|
action: member
|
||||||
state: absent
|
state: absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
@@ -378,6 +389,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | upper }}"
|
- "{{ hbacsvc_list[1] | upper }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | upper }}"
|
- "{{ hbacsvcgroup_list[0] | upper }}"
|
||||||
|
- SUDO
|
||||||
action: member
|
action: member
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
@@ -403,6 +415,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | upper }}"
|
- "{{ hbacsvc_list[1] | upper }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | upper }}"
|
- "{{ hbacsvcgroup_list[0] | upper }}"
|
||||||
|
- SUDO
|
||||||
action: member
|
action: member
|
||||||
state: absent
|
state: absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
@@ -449,6 +462,7 @@
|
|||||||
- "{{ hbacsvc_list[1] | lower }}"
|
- "{{ hbacsvc_list[1] | lower }}"
|
||||||
hbacsvcgroup:
|
hbacsvcgroup:
|
||||||
- "{{ hbacsvcgroup_list[0] | lower }}"
|
- "{{ hbacsvcgroup_list[0] | lower }}"
|
||||||
|
- sudo
|
||||||
action: member
|
action: member
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|||||||
Reference in New Issue
Block a user