Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
fdbbb171
Commit
fdbbb171
authored
Feb 17, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach the user module to understand check mode.
parent
43d22b0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
library/user
+13
-3
No files found.
library/user
View file @
fdbbb171
...
...
@@ -333,8 +333,8 @@ class User(object):
cmd
.
append
(
','
.
join
(
groups
))
if
self
.
comment
is
not
None
and
info
[
4
]
!=
self
.
comment
:
cmd
.
append
(
'-c'
)
cmd
.
append
(
self
.
comment
)
cmd
.
append
(
'-c'
)
cmd
.
append
(
self
.
comment
)
if
self
.
home
is
not
None
and
info
[
5
]
!=
self
.
home
:
cmd
.
append
(
'-d'
)
...
...
@@ -351,6 +351,8 @@ class User(object):
# skip if no changes to be made
if
len
(
cmd
)
==
1
:
return
(
None
,
''
,
''
)
elif
self
.
check_mode
:
return
(
True
,
''
,
''
)
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
...
...
@@ -947,6 +949,8 @@ class AIX(User):
# skip if no changes to be made
if
len
(
cmd
)
==
1
:
(
rc
,
out
,
err
)
=
(
None
,
''
,
''
)
elif
self
.
check_mode
:
return
(
True
,
''
,
''
)
else
:
cmd
.
append
(
self
.
name
)
(
rc
,
out
,
err
)
=
self
.
execute_command
(
cmd
)
...
...
@@ -1002,7 +1006,8 @@ def main():
ssh_key_file
=
dict
(
default
=
None
),
ssh_key_comment
=
dict
(
default
=
ssh_defaults
[
'comment'
]),
ssh_key_passphrase
=
dict
(
default
=
None
)
)
),
supports_check_mode
=
True
)
user
=
User
(
module
)
...
...
@@ -1021,6 +1026,8 @@ def main():
result
[
'state'
]
=
user
.
state
if
user
.
state
==
'absent'
:
if
user
.
user_exists
():
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
(
rc
,
out
,
err
)
=
user
.
remove_user
()
if
rc
!=
0
:
module
.
fail_json
(
name
=
user
.
name
,
msg
=
err
,
rc
=
rc
)
...
...
@@ -1028,10 +1035,13 @@ def main():
result
[
'remove'
]
=
user
.
remove
elif
user
.
state
==
'present'
:
if
not
user
.
user_exists
():
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
(
rc
,
out
,
err
)
=
user
.
create_user
()
result
[
'system'
]
=
user
.
system
result
[
'createhome'
]
=
user
.
createhome
else
:
# modify user (note: this function is check mode aware)
(
rc
,
out
,
err
)
=
user
.
modify_user
()
result
[
'append'
]
=
user
.
append
if
rc
is
not
None
and
rc
!=
0
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment