Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ansible FreeIPA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
37ba14f1
Unverified
Commit
37ba14f1
authored
3 years ago
by
Thomas Woerner
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #685 from rjeffman/hbacsvcgroup_case_insensitive
hbacsvcgroup: Fix member management idempotence issues.
parents
9b882071
b140f04a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/modules/ipahbacsvcgroup.py
+30
-26
30 additions, 26 deletions
plugins/modules/ipahbacsvcgroup.py
tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml
+233
-0
233 additions, 0 deletions
...bacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml
with
263 additions
and
26 deletions
plugins/modules/ipahbacsvcgroup.py
+
30
−
26
View file @
37ba14f1
...
...
@@ -101,7 +101,8 @@ RETURN = """
"""
from
ansible.module_utils.ansible_freeipa_module
import
\
IPAAnsibleModule
,
compare_args_ipa
,
gen_add_del_lists
IPAAnsibleModule
,
compare_args_ipa
,
gen_add_del_lists
,
gen_add_list
,
\
gen_intersection_list
def
find_hbacsvcgroup
(
module
,
name
):
...
...
@@ -183,7 +184,7 @@ def main():
# present
description
=
ansible_module
.
params_get
(
"
description
"
)
nomembers
=
ansible_module
.
params_get
(
"
nomembers
"
)
hbacsvc
=
ansible_module
.
params_get
(
"
hbacsvc
"
)
hbacsvc
=
ansible_module
.
params_get
_lowercase
(
"
hbacsvc
"
)
action
=
ansible_module
.
params_get
(
"
action
"
)
# state
state
=
ansible_module
.
params_get
(
"
state
"
)
...
...
@@ -223,6 +224,8 @@ def main():
# Make sure hbacsvcgroup exists
res_find
=
find_hbacsvcgroup
(
ansible_module
,
name
)
hbacsvc_add
,
hbacsvc_del
=
[],
[]
# Create command
if
state
==
"
present
"
:
# Generate args
...
...
@@ -246,32 +249,20 @@ def main():
if
not
compare_args_ipa
(
ansible_module
,
member_args
,
res_find
):
# Generate addition and removal lists
hbacsvc_add
,
hbacsvc_del
=
gen_add_del_lists
(
hbacsvc
,
res_find
.
get
(
"
member_hbacsvc
"
))
if
hbacsvc
is
not
None
:
hbacsvc_add
,
hbacsvc_del
=
gen_add_del_lists
(
hbacsvc
,
res_find
.
get
(
"
member_hbacsvc
"
))
# Add members
if
len
(
hbacsvc_add
)
>
0
:
commands
.
append
([
name
,
"
hbacsvcgroup_add_member
"
,
{
"
hbacsvc
"
:
hbacsvc_add
}])
# Remove members
if
len
(
hbacsvc_del
)
>
0
:
commands
.
append
([
name
,
"
hbacsvcgroup_remove_member
"
,
{
"
hbacsvc
"
:
hbacsvc_del
}])
elif
action
==
"
member
"
:
if
res_find
is
None
:
ansible_module
.
fail_json
(
msg
=
"
No hbacsvcgroup
'
%s
'"
%
name
)
# Ensure members are present
commands
.
append
([
name
,
"
hbacsvcgroup_add_member
"
,
{
"
hbacsvc
"
:
hbacsvc
}])
if
hbacsvc
:
hbacsvc_add
=
gen_add_list
(
hbacsvc
,
res_find
.
get
(
"
member_
hbacsvc
"
))
elif
state
==
"
absent
"
:
if
action
==
"
hbacsvcgroup
"
:
if
res_find
is
not
None
:
...
...
@@ -283,15 +274,28 @@ def main():
msg
=
"
No hbacsvcgroup
'
%s
'"
%
name
)
# Ensure members are absent
commands
.
append
([
name
,
"
hbacsvcgroup_remove_member
"
,
{
"
hbacsvc
"
:
hbacsvc
}])
if
hbacsvc
:
hbacsvc_del
=
gen_intersection_list
(
hbacsvc
,
res_find
.
get
(
"
member_
hbacsvc
"
))
else
:
ansible_module
.
fail_json
(
msg
=
"
Unkown state
'
%s
'"
%
state
)
# Execute commands
# Manage members
if
len
(
hbacsvc_add
)
>
0
:
commands
.
append
([
name
,
"
hbacsvcgroup_add_member
"
,
{
"
hbacsvc
"
:
hbacsvc_add
}])
# Remove members
if
len
(
hbacsvc_del
)
>
0
:
commands
.
append
([
name
,
"
hbacsvcgroup_remove_member
"
,
{
"
hbacsvc
"
:
hbacsvc_del
}])
# Execute commands
changed
=
ansible_module
.
execute_ipa_commands
(
commands
,
result_handler
)
# Done
...
...
This diff is collapsed.
Click to expand it.
tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml
0 → 100644
+
233
−
0
View file @
37ba14f1
---
-
name
:
Test hbacsvcgroup member varying capitalization
hosts
:
"
{{
ipa_test_host
|
default('ipaserver')
}}"
become
:
no
gather_facts
:
no
vars
:
hbacsvc_list
:
-
sVc1
-
SvC2
tasks
:
-
block
:
-
name
:
Ensure test hbacsvcgroup is absent
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
state
:
absent
-
name
:
Ensure test HBAC services are present
ipahbacsvc
:
ipaadmin_password
:
SomeADMINpassword
name
:
"
{{
item
}}"
with_items
:
"
{{
hbacsvc_list
}}"
-
name
:
Ensure test hbacsvcgroup is present with duplicate hbacsvc
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
-
sVc1
-
SvC1
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Ensure test hbacsvc is absent from hbacsvcgroup, with duplicate hbacsvc
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
-
sVc1
-
SvC1
action
:
member
state
:
absent
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Check if test hbacsvc absent, again, from hbacsvcgroup, with duplicate hbacsvc, would trigger changes
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
-
svC1
-
SVC1
action
:
member
state
:
absent
check_mode
:
yes
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure test hbacsvcgroup is absent
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
state
:
absent
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Check if hbacsvcgroup with members would trigger changes, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
check_mode
:
yes
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Ensure hbacsvcgroup is present with members, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Check if hbacsvcgroup with members would not trigger changes, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
check_mode
:
yes
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup is present with members, lowercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
lower
}}"
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup is present with members, uppercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
upper
}}"
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure test hbacsvcgroup is absent
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
state
:
absent
-
name
:
Ensure test hbacsvcgroup is present
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
-
name
:
Check if hbacsvcgroup members would trigger changes, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
action
:
member
check_mode
:
yes
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
action
:
member
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Check if hbacsvcgroup members would not trigger changes, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
action
:
member
check_mode
:
yes
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members, lowercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
lower
}}"
action
:
member
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members, uppercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
upper
}}"
action
:
member
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Check if hbacsvcgroup members absence would trigger changes, uppercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
upper
}}"
action
:
member
state
:
absent
check_mode
:
yes
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members absent, uppercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
upper
}}"
action
:
member
state
:
absent
register
:
result
failed_when
:
not result.changed or result.failed
-
name
:
Check if hbacsvcgroup members absence would not trigger changes, uppercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
upper
}}"
action
:
member
state
:
absent
check_mode
:
yes
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members absent, mixed case
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
}}"
action
:
member
state
:
absent
register
:
result
failed_when
:
result.changed or result.failed
-
name
:
Ensure hbacsvcgroup has members absent, lowercase
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
hbacsvc
:
"
{{
hbacsvc_list
|
lower
}}"
action
:
member
state
:
absent
register
:
result
failed_when
:
result.changed or result.failed
always
:
-
name
:
Ensure test hbac service group is absent
ipahbacsvcgroup
:
ipaadmin_password
:
SomeADMINpassword
name
:
testgroup
state
:
absent
-
name
:
Ensure test hbac services are absent
ipahbacsvc
:
ipaadmin_password
:
SomeADMINpassword
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
"
{{
hbacsvc_list
}}"
state
:
absent
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment