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
a379d58c
Commit
a379d58c
authored
Mar 28, 2012
by
Stephen Fromm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop support of group membership in group module
Use the user module to define group membership.
parent
97776537
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
51 deletions
+0
-51
library/group
+0
-51
No files found.
library/group
View file @
a379d58c
...
...
@@ -30,7 +30,6 @@ import sys
GROUPADD
=
"/usr/sbin/groupadd"
GROUPDEL
=
"/usr/sbin/groupdel"
GROUPMOD
=
"/usr/sbin/groupmod"
GPASSWD
=
"/usr/bin/gpasswd"
def
debug
(
msg
):
# ansible ignores stderr, so it's safe to use for debug
...
...
@@ -54,7 +53,6 @@ def add_group_info(kwargs):
kwargs
[
'state'
]
=
'present'
info
=
group_info
(
name
)
kwargs
[
'gid'
]
=
info
[
2
]
kwargs
[
'members'
]
=
info
[
3
]
else
:
kwargs
[
'state'
]
=
'absent'
return
kwargs
...
...
@@ -100,33 +98,6 @@ def group_mod(group, **kwargs):
else
:
return
False
def
group_has_member
(
group
,
member
):
if
not
group_exists
(
group
):
return
False
info
=
group_info
(
group
)
if
member
in
info
[
3
]:
return
True
else
:
return
False
def
group_add_member
(
group
,
member
):
cmd
=
[
GPASSWD
,
'-a'
,
member
,
group
]
debug
(
"Arguments to gpasswd:
%
s"
%
(
" "
.
join
(
cmd
)))
rc
=
subprocess
.
call
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
rc
==
0
:
return
True
else
:
return
False
def
group_del_member
(
group
,
member
):
cmd
=
[
GPASSWD
,
'-d'
,
member
,
group
]
debug
(
"Arguments to gpasswd:
%
s"
%
(
" "
.
join
(
cmd
)))
rc
=
subprocess
.
call
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
rc
==
0
:
return
True
else
:
return
False
def
group_exists
(
group
):
try
:
if
grp
.
getgrnam
(
group
):
...
...
@@ -160,11 +131,6 @@ if not os.path.exists(GROUPMOD):
GROUPDEL
=
"/sbin/groupmod"
else
:
fail_json
(
msg
=
"Cannot find groupmod"
)
if
not
os
.
path
.
exists
(
GPASSWD
):
if
os
.
path
.
exists
(
"/bin/gpasswd"
):
GROUPDEL
=
"/bin/gpasswd"
else
:
fail_json
(
msg
=
"Cannot find gpasswd"
)
if
len
(
sys
.
argv
)
==
2
and
os
.
path
.
exists
(
sys
.
argv
[
1
]):
argfile
=
sys
.
argv
[
1
]
...
...
@@ -186,15 +152,8 @@ state = params.get('state','present')
name
=
params
.
get
(
'name'
,
None
)
gid
=
params
.
get
(
'gid'
,
None
)
# ===========================================
# the following controls group membership
member
=
params
.
get
(
'member'
,
None
)
memberstate
=
params
.
get
(
'memberstate'
,
'present'
)
if
state
not
in
[
'present'
,
'absent'
]:
fail_json
(
msg
=
'invalid state'
)
if
memberstate
not
in
[
'present'
,
'absent'
]:
fail_json
(
msg
=
'invalid memberstate'
)
if
name
is
None
:
fail_json
(
msg
=
'name is required'
)
...
...
@@ -210,16 +169,6 @@ elif state == 'present':
else
:
changed
=
group_mod
(
name
,
gid
=
gid
)
if
member
is
not
None
:
if
memberstate
==
'present'
:
if
not
group_has_member
(
name
,
member
):
changed
=
group_add_member
(
name
,
member
)
elif
memberstate
==
'absent'
:
if
group_has_member
(
name
,
member
):
changed
=
group_del_member
(
name
,
member
)
else
:
fail_json
(
name
=
name
,
msg
=
'Unexpected position reached'
)
exit_json
(
name
=
name
,
changed
=
changed
)
fail_json
(
name
=
name
,
msg
=
'Unexpected position reached'
)
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