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
74e954b9
Unverified
Commit
74e954b9
authored
Oct 2, 2019
by
Varun Mylaraiah
Committed by
GitHub
Oct 2, 2019
Browse files
Options
Downloads
Plain Diff
Merge pull request #123 from t-woerner/ipagroup-rework
ipagroup: Rework to use same mechanisms as ipahostgroup module
parents
00066d2c
c5e0b1b4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/modules/ipagroup.py
+32
-41
32 additions, 41 deletions
plugins/modules/ipagroup.py
with
32 additions
and
41 deletions
plugins/modules/ipagroup.py
+
32
−
41
View file @
74e954b9
...
@@ -347,19 +347,6 @@ def main():
...
@@ -347,19 +347,6 @@ def main():
if
res_find
is
None
:
if
res_find
is
None
:
ansible_module
.
fail_json
(
msg
=
"
No group
'
%s
'"
%
name
)
ansible_module
.
fail_json
(
msg
=
"
No group
'
%s
'"
%
name
)
user_add
=
list
(
set
(
user
or
[])
-
set
(
res_find
.
get
(
"
member_user
"
,
[])))
group_add
=
list
(
set
(
group
or
[])
-
set
(
res_find
.
get
(
"
member_group
"
,
[])))
service_add
=
list
(
set
(
service
or
[])
-
set
(
res_find
.
get
(
"
member_service
"
,
[])))
# Add members
if
len
(
user_add
)
>
0
or
len
(
group_add
)
>
0
or
\
len
(
service_add
)
>
0
:
commands
.
append
([
name
,
"
group_add_member
"
,
commands
.
append
([
name
,
"
group_add_member
"
,
{
{
"
user
"
:
user
,
"
user
"
:
user
,
...
@@ -376,20 +363,6 @@ def main():
...
@@ -376,20 +363,6 @@ def main():
if
res_find
is
None
:
if
res_find
is
None
:
ansible_module
.
fail_json
(
msg
=
"
No group
'
%s
'"
%
name
)
ansible_module
.
fail_json
(
msg
=
"
No group
'
%s
'"
%
name
)
# Remove intersection member
user_del
=
list
(
set
(
user
or
[])
&
set
(
res_find
.
get
(
"
member_user
"
,
[])))
group_del
=
list
(
set
(
group
or
[])
&
set
(
res_find
.
get
(
"
member_group
"
,
[])))
service_del
=
list
(
set
(
service
or
[])
&
set
(
res_find
.
get
(
"
member_service
"
,
[])))
# Remove members
if
len
(
user_del
)
>
0
or
len
(
group_del
)
>
0
or
\
len
(
service_del
)
>
0
:
commands
.
append
([
name
,
"
group_remove_member
"
,
commands
.
append
([
name
,
"
group_remove_member
"
,
{
{
"
user
"
:
user
,
"
user
"
:
user
,
...
@@ -403,11 +376,29 @@ def main():
...
@@ -403,11 +376,29 @@ def main():
for
name
,
command
,
args
in
commands
:
for
name
,
command
,
args
in
commands
:
try
:
try
:
api_command
(
ansible_module
,
command
,
to_text
(
name
),
args
)
result
=
api_command
(
ansible_module
,
command
,
to_text
(
name
),
args
)
if
"
completed
"
in
result
and
result
[
"
completed
"
]
>
0
:
changed
=
True
changed
=
True
except
Exception
as
e
:
except
Exception
as
e
:
ansible_module
.
fail_json
(
msg
=
"
%s: %s: %s
"
%
(
command
,
name
,
ansible_module
.
fail_json
(
msg
=
"
%s: %s: %s
"
%
(
command
,
name
,
str
(
e
)))
str
(
e
)))
# Get all errors
# All "already a member" and "not a member" failures in the
# result are ignored. All others are reported.
errors
=
[]
if
"
failed
"
in
result
and
len
(
result
[
"
failed
"
])
>
0
:
for
item
in
result
[
"
failed
"
]:
failed_item
=
result
[
"
failed
"
][
item
]
for
member_type
in
failed_item
:
for
member
,
failure
in
failed_item
[
member_type
]:
if
"
already a member
"
in
failure
\
or
"
not a member
"
in
failure
:
continue
errors
.
append
(
"
%s: %s %s: %s
"
%
(
command
,
member_type
,
member
,
failure
))
if
len
(
errors
)
>
0
:
ansible_module
.
fail_json
(
msg
=
"
,
"
.
join
(
errors
))
except
Exception
as
e
:
except
Exception
as
e
:
ansible_module
.
fail_json
(
msg
=
str
(
e
))
ansible_module
.
fail_json
(
msg
=
str
(
e
))
...
...
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
sign in
to comment