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
4a470019
Unverified
Commit
4a470019
authored
3 years ago
by
Thomas Woerner
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #716 from rjeffman/iparole_add_state_renamed
iparole: Add state 'renamed'.
parents
8c88413a
68f77584
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/modules/iparole.py
+23
-7
23 additions, 7 deletions
plugins/modules/iparole.py
tests/role/test_role.yml
+3
-1
3 additions, 1 deletion
tests/role/test_role.yml
with
26 additions
and
8 deletions
plugins/modules/iparole.py
+
23
−
7
View file @
4a470019
...
...
@@ -72,7 +72,7 @@ options:
required: false
state:
description: The state to ensure.
choices: [
"
present
"
,
"
absent
"
]
choices: [
"
present
"
,
"
absent
"
,
"
renamed
"
]
default: present
required: true
"""
...
...
@@ -145,9 +145,22 @@ def check_parameters(module):
invalid
=
[]
if
state
==
"
renamed
"
:
if
action
==
"
member
"
:
module
.
fail_json
(
msg
=
"
Invalid action
'
member
'
with state
'
renamed
'
.
"
)
invalid
=
[
"
description
"
,
"
user
"
,
"
group
"
,
"
host
"
,
"
hostgroup
"
,
"
service
"
,
"
privilege
"
,
]
if
state
==
"
present
"
:
invalid
=
[
"
rename
"
]
if
action
==
"
member
"
:
invalid
.
extend
([
'
description
'
,
'
rename
'
])
invalid
.
extend
([
'
description
'
])
if
state
==
"
absent
"
:
invalid
.
extend
([
'
description
'
,
'
rename
'
])
...
...
@@ -335,17 +348,20 @@ def role_commands_for_name(module, state, action, name):
"""
Define commands for the Role module.
"""
commands
=
[]
rename
=
module
.
params_get
(
"
rename
"
)
res_find
=
find_role
(
module
,
name
)
if
state
==
"
renamed
"
:
args
=
gen_args
(
module
)
if
res_find
is
None
:
module
.
fail_json
(
msg
=
"
No role
'
%s
'"
%
name
)
else
:
commands
.
append
([
name
,
'
role_mod
'
,
args
])
if
state
==
"
present
"
:
args
=
gen_args
(
module
)
if
action
==
"
role
"
:
if
res_find
is
None
:
if
rename
is
not
None
:
module
.
fail_json
(
msg
=
"
Cannot `rename` inexistent role.
"
)
commands
.
append
([
name
,
'
role_add
'
,
args
])
res_find
=
{}
else
:
...
...
@@ -391,7 +407,7 @@ def create_module():
action
=
dict
(
type
=
"
str
"
,
default
=
"
role
"
,
choices
=
[
"
role
"
,
"
member
"
]),
state
=
dict
(
type
=
"
str
"
,
default
=
"
present
"
,
choices
=
[
"
present
"
,
"
absent
"
]),
choices
=
[
"
present
"
,
"
absent
"
,
"
renamed
"
]),
),
supports_check_mode
=
True
,
mutually_exclusive
=
[],
...
...
This diff is collapsed.
Click to expand it.
tests/role/test_role.yml
+
3
−
1
View file @
4a470019
...
...
@@ -36,6 +36,7 @@
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
renamerole
rename
:
testrole
state
:
renamed
register
:
result
failed_when
:
not result.changed or result.failed
...
...
@@ -47,8 +48,9 @@
ipaapi_context
:
"
{{
ipa_context
|
default(omit)
}}"
name
:
renamerole
rename
:
testrole
state
:
renamed
register
:
result
failed_when
:
result.changed
failed_when
:
result.changed
or (not result.failed and "No role 'renamerole'" not in result.msg)
-
name
:
Ensure role has member has privileges.
iparole
:
...
...
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