FreeBSD group operations is now supported properly.

pull/2863/head
lonerr 12 years ago
parent e075607c9b
commit dcb22d1760

@ -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():
module = AnsibleModule(
argument_spec = dict(

Loading…
Cancel
Save