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
788680a1
Commit
788680a1
authored
Jun 03, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'devel' of
git://github.com/trbs/ansible
into more_users
parents
57f4e808
3b3afe22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
11 deletions
+97
-11
library/system/group
+97
-11
library/system/user
+0
-0
No files found.
library/system/group
View file @
788680a1
...
...
@@ -61,8 +61,8 @@ import platform
class
Group
(
object
):
"""
This is a generic Group manipulation class that is subclassed
based on platform.
based on platform.
A subclass may wish to override the following action methods:-
- group_del()
- group_add()
...
...
@@ -96,7 +96,7 @@ class Group(object):
def
group_del
(
self
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupdel'
,
True
),
self
.
name
]
return
self
.
execute_command
(
cmd
)
def
group_add
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupadd'
,
True
)]
for
key
in
kwargs
:
...
...
@@ -107,7 +107,7 @@ class Group(object):
cmd
.
append
(
'-r'
)
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
def
group_mod
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupmod'
,
True
)]
info
=
self
.
group_info
()
...
...
@@ -122,14 +122,14 @@ class Group(object):
return
(
True
,
''
,
''
)
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
def
group_exists
(
self
):
try
:
if
grp
.
getgrnam
(
self
.
name
):
return
True
except
KeyError
:
return
False
def
group_info
(
self
):
if
not
self
.
group_exists
():
return
False
...
...
@@ -162,7 +162,7 @@ class SunOS(Group):
cmd
.
append
(
kwargs
[
key
])
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
# ===========================================
...
...
@@ -228,25 +228,111 @@ class FreeBsdGroup(Group):
cmd
=
[
self
.
module
.
get_bin_path
(
'pw'
,
True
),
'groupdel'
,
self
.
name
]
return
self
.
execute_command
(
cmd
)
def
group_add
(
self
,
**
kwargs
):
def
group_add
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'pw'
,
True
),
'groupadd'
,
self
.
name
]
if
self
.
gid
is
not
None
:
cmd
.
append
(
'-g
%
d'
%
int
(
self
.
gid
))
cmd
.
append
(
'-g
%
d'
%
int
(
self
.
gid
))
return
self
.
execute_command
(
cmd
)
def
group_mod
(
self
,
**
kwargs
):
def
group_mod
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'pw'
,
True
),
'groupmod'
,
self
.
name
]
info
=
self
.
group_info
()
cmd_len
=
len
(
cmd
)
if
self
.
gid
is
not
None
and
int
(
self
.
gid
)
!=
info
[
2
]:
cmd
.
append
(
'-g
%
d'
%
int
(
self
.
gid
))
cmd
.
append
(
'-g
%
d'
%
int
(
self
.
gid
))
# modify the group if cmd will do anything
if
cmd_len
!=
len
(
cmd
):
if
self
.
module
.
check_mode
:
return
(
True
,
''
,
''
)
return
self
.
execute_command
(
cmd
)
return
(
None
,
''
,
''
)
# ===========================================
class
OpenBsdGroup
(
Group
):
"""
This is a OpenBSD Group manipulation class.
This overrides the following methods from the generic class:-
- group_del()
- group_add()
- group_mod()
"""
platform
=
'OpenBSD'
distribution
=
None
GROUPFILE
=
'/etc/group'
def
group_del
(
self
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupdel'
,
True
),
self
.
name
]
return
self
.
execute_command
(
cmd
)
def
group_add
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupadd'
,
True
)]
if
self
.
gid
is
not
None
:
cmd
.
append
(
'-g'
)
cmd
.
append
(
'
%
d'
%
int
(
self
.
gid
))
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
def
group_mod
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupmod'
,
True
)]
info
=
self
.
group_info
()
cmd_len
=
len
(
cmd
)
if
self
.
gid
is
not
None
and
int
(
self
.
gid
)
!=
info
[
2
]:
cmd
.
append
(
'-g'
)
cmd
.
append
(
'
%
d'
%
int
(
self
.
gid
))
if
len
(
cmd
)
==
1
:
return
(
None
,
''
,
''
)
if
self
.
module
.
check_mode
:
return
(
True
,
''
,
''
)
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
# ===========================================
class
NetBsdGroup
(
Group
):
"""
This is a NetBSD Group manipulation class.
This overrides the following methods from the generic class:-
- group_del()
- group_add()
- group_mod()
"""
platform
=
'NetBSD'
distribution
=
None
GROUPFILE
=
'/etc/group'
def
group_del
(
self
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupdel'
,
True
),
self
.
name
]
return
self
.
execute_command
(
cmd
)
def
group_add
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupadd'
,
True
)]
if
self
.
gid
is
not
None
:
cmd
.
append
(
'-g'
)
cmd
.
append
(
'
%
d'
%
int
(
self
.
gid
))
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
def
group_mod
(
self
,
**
kwargs
):
cmd
=
[
self
.
module
.
get_bin_path
(
'groupmod'
,
True
)]
info
=
self
.
group_info
()
cmd_len
=
len
(
cmd
)
if
self
.
gid
is
not
None
and
int
(
self
.
gid
)
!=
info
[
2
]:
cmd
.
append
(
'-g'
)
cmd
.
append
(
'
%
d'
%
int
(
self
.
gid
))
if
len
(
cmd
)
==
1
:
return
(
None
,
''
,
''
)
if
self
.
module
.
check_mode
:
return
(
True
,
''
,
''
)
cmd
.
append
(
self
.
name
)
return
self
.
execute_command
(
cmd
)
# ===========================================
def
main
():
module
=
AnsibleModule
(
argument_spec
=
dict
(
...
...
library/system/user
View file @
788680a1
This diff is collapsed.
Click to expand it.
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