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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
5c630d60
Unverified
Commit
5c630d60
authored
Jan 5, 2023
by
Rafael Guterres Jeffman
Committed by
GitHub
Jan 5, 2023
Browse files
Options
Downloads
Plain Diff
Merge pull request #1003 from dkarpele/dkarpele-2144724
Use netgroup_find instead of netgroup_show to workaround IPA bug.
parents
ba353a9b
483d51b4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/modules/ipanetgroup.py
+19
-8
19 additions, 8 deletions
plugins/modules/ipanetgroup.py
tests/netgroup/test_netgroup.yml
+33
-1
33 additions, 1 deletion
tests/netgroup/test_netgroup.yml
with
52 additions
and
9 deletions
plugins/modules/ipanetgroup.py
+
19
−
8
View file @
5c630d60
...
@@ -157,18 +157,29 @@ RETURN = """
...
@@ -157,18 +157,29 @@ RETURN = """
from
ansible.module_utils.ansible_freeipa_module
import
\
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
,
ipalib_errors
,
ensure_fqdn
gen_add_list
,
gen_intersection_list
,
ensure_fqdn
def
find_netgroup
(
module
,
name
):
def
find_netgroup
(
module
,
name
):
"""
Find if a netgroup with the given name already exist.
"""
"""
Find if a netgroup with the given name already exist.
"""
try
:
_args
=
{
_result
=
module
.
ipa_command
(
"
netgroup_show
"
,
name
,
{
"
all
"
:
True
})
"
all
"
:
True
,
except
ipalib_errors
.
NotFound
:
"
cn
"
:
name
,
# An exception is raised if netgroup name is not found.
}
# `netgroup_find` is used here instead of `netgroup_show` to workaround
# FreeIPA bug https://pagure.io/freeipa/issue/9284.
# `ipa netgroup-show hostgroup` shows hostgroup - it's a bug.
# `ipa netgroup-find hostgroup` doesn't show hostgroup - it's correct.
_result
=
module
.
ipa_command
(
"
netgroup_find
"
,
name
,
_args
)
if
len
(
_result
[
"
result
"
])
>
1
:
module
.
fail_json
(
msg
=
"
There is more than one netgroup
'
%s
'"
%
name
)
elif
len
(
_result
[
"
result
"
])
==
1
:
return
_result
[
"
result
"
][
0
]
return
None
return
None
else
:
return
_result
[
"
result
"
]
def
gen_args
(
description
,
nisdomain
,
nomembers
):
def
gen_args
(
description
,
nisdomain
,
nomembers
):
...
...
This diff is collapsed.
Click to expand it.
tests/netgroup/test_netgroup.yml
+
33
−
1
View file @
5c630d60
...
@@ -17,6 +17,14 @@
...
@@ -17,6 +17,14 @@
-
my_netgroup3
-
my_netgroup3
state
:
absent
state
:
absent
-
name
:
Ensure hostgroup is absent
ipahostgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
-
my_hostgroup1
state
:
absent
# CREATE TEST ITEMS
# CREATE TEST ITEMS
-
name
:
Get Domain from server name
-
name
:
Get Domain from server name
ansible.builtin.set_fact
:
ansible.builtin.set_fact
:
...
@@ -35,6 +43,12 @@
...
@@ -35,6 +43,12 @@
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
my_netgroup3
name
:
my_netgroup3
-
name
:
Ensure hostgroup my_hostgroup1 is present
ipahostgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
my_hostgroup1
# TESTS
# TESTS
-
name
:
Ensure netgroup my_netgroup1 is present
-
name
:
Ensure netgroup my_netgroup1 is present
...
@@ -115,7 +129,7 @@
...
@@ -115,7 +129,7 @@
register
:
result
register
:
result
failed_when
:
result.changed or result.failed
failed_when
:
result.changed or result.failed
# netgroup and hostgroup with the same name are deprecated
# netgroup and hostgroup with the same name are deprecated
(check hostgroup)
-
name
:
Ensure hostgroup my_netgroup2 isn't present
-
name
:
Ensure hostgroup my_netgroup2 isn't present
ipahostgroup
:
ipahostgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaadmin_password
:
SomeADMINpassword
...
@@ -125,6 +139,16 @@
...
@@ -125,6 +139,16 @@
failed_when
:
result.changed or not result.failed or
failed_when
:
result.changed or not result.failed or
"Hostgroups and netgroups share a common namespace" not in result.msg
"Hostgroups and netgroups share a common namespace" not in result.msg
# netgroup and hostgroup with the same name are deprecated (check netgroup)
-
name
:
Ensure netgroup my_hostgroup1 isn't present
ipanetgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
my_hostgroup1
register
:
result
failed_when
:
result.changed or not result.failed or
"Hostgroups and netgroups share a common namespace" not in result.msg
-
name
:
Ensure netgroups my_netgroup2, my_netgroup3 are absent
-
name
:
Ensure netgroups my_netgroup2, my_netgroup3 are absent
ipanetgroup
:
ipanetgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaadmin_password
:
SomeADMINpassword
...
@@ -147,3 +171,11 @@
...
@@ -147,3 +171,11 @@
-
my_netgroup2
-
my_netgroup2
-
my_netgroup3
-
my_netgroup3
state
:
absent
state
:
absent
-
name
:
Ensure hostgroups are absent
ipahostgroup
:
ipaadmin_password
:
SomeADMINpassword
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
-
my_hostgroup1
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