Merge pull request #2863 from lonerr/freebsd-group
FreeBSD group operations is now supported properly.
This commit is contained in:
commit
53db51a0a2
1 changed files with 37 additions and 0 deletions
|
@ -210,6 +210,43 @@ class AIX(Group):
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
|
class FreeBsdGroup(Group):
|
||||||
|
"""
|
||||||
|
This is a FreeBSD Group manipulation class.
|
||||||
|
|
||||||
|
This overrides the following methods from the generic class:-
|
||||||
|
- group_del()
|
||||||
|
- group_add()
|
||||||
|
- group_mod()
|
||||||
|
"""
|
||||||
|
|
||||||
|
platform = 'FreeBSD'
|
||||||
|
distribution = None
|
||||||
|
GROUPFILE = '/etc/group'
|
||||||
|
|
||||||
|
def group_del(self):
|
||||||
|
cmd = [self.module.get_bin_path('pw', True), 'groupdel', self.name]
|
||||||
|
return self.execute_command(cmd)
|
||||||
|
|
||||||
|
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))
|
||||||
|
return self.execute_command(cmd)
|
||||||
|
|
||||||
|
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))
|
||||||
|
# modify the group if cmd will do anything
|
||||||
|
if cmd_len != len(cmd):
|
||||||
|
return self.execute_command(cmd)
|
||||||
|
return (None, '', '')
|
||||||
|
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
Loading…
Reference in a new issue