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
594084bc
Commit
594084bc
authored
May 01, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #287 from dne/user-group-add-system
Add 'system' option for user and group modules
parents
af74c741
a837009c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
library/group
+6
-1
library/user
+7
-1
No files found.
library/group
View file @
594084bc
...
...
@@ -65,6 +65,8 @@ def group_add(group, **kwargs):
if
key
==
'gid'
and
kwargs
[
key
]
is
not
None
:
cmd
.
append
(
'-g'
)
cmd
.
append
(
kwargs
[
key
])
elif
key
==
'system'
and
kwargs
[
key
]
==
'yes'
:
cmd
.
append
(
'-r'
)
cmd
.
append
(
group
)
rc
=
subprocess
.
call
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
rc
==
0
:
...
...
@@ -142,9 +144,12 @@ for x in items:
state
=
params
.
get
(
'state'
,
'present'
)
name
=
params
.
get
(
'name'
,
None
)
gid
=
params
.
get
(
'gid'
,
None
)
system
=
params
.
get
(
'system'
,
'no'
)
if
state
not
in
[
'present'
,
'absent'
]:
fail_json
(
msg
=
'invalid state'
)
if
system
not
in
[
'yes'
,
'no'
]:
fail_json
(
msg
=
'invalid system'
)
if
name
is
None
:
fail_json
(
msg
=
'name is required'
)
...
...
@@ -156,7 +161,7 @@ if state == 'absent':
exit_json
(
name
=
name
,
changed
=
changed
)
elif
state
==
'present'
:
if
not
group_exists
(
name
):
changed
=
group_add
(
name
,
gid
=
gid
)
changed
=
group_add
(
name
,
gid
=
gid
,
system
=
system
)
else
:
changed
=
group_mod
(
name
,
gid
=
gid
)
...
...
library/user
View file @
594084bc
...
...
@@ -110,6 +110,8 @@ def user_add(user, **kwargs):
cmd
.
append
(
'-m'
)
else
:
cmd
.
append
(
'-M'
)
elif
key
==
'system'
and
kwargs
[
key
]
==
'yes'
:
cmd
.
append
(
'-r'
)
cmd
.
append
(
user
)
rc
=
subprocess
.
call
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
rc
==
0
:
...
...
@@ -269,6 +271,7 @@ remove = params.get('remove', False)
# ===========================================
# following options are specific to useradd
createhome
=
params
.
get
(
'createhome'
,
'yes'
)
system
=
params
.
get
(
'system'
,
'no'
)
# ===========================================
# following options are specific to usermod
...
...
@@ -278,6 +281,8 @@ if state not in [ 'present', 'absent' ]:
fail_json
(
msg
=
'invalid state'
)
if
createhome
not
in
[
'yes'
,
'no'
]:
fail_json
(
msg
=
'invalid createhome'
)
if
system
not
in
[
'yes'
,
'no'
]:
fail_json
(
msg
=
'invalid system'
)
if
append
not
in
[
'yes'
,
'no'
]:
fail_json
(
msg
=
'invalid append'
)
if
name
is
None
:
...
...
@@ -293,7 +298,8 @@ elif state == 'present':
if
not
user_exists
(
name
):
changed
=
user_add
(
name
,
uid
=
uid
,
group
=
group
,
groups
=
groups
,
comment
=
comment
,
home
=
home
,
shell
=
shell
,
password
=
password
,
createhome
=
createhome
)
password
=
password
,
createhome
=
createhome
,
system
=
system
)
else
:
changed
=
user_mod
(
name
,
uid
=
uid
,
group
=
group
,
groups
=
groups
,
comment
=
comment
,
home
=
home
,
shell
=
shell
,
...
...
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