From 384798145ab32bb7fd05582cc0a546db85e1404b Mon Sep 17 00:00:00 2001 From: lonerr Date: Wed, 8 May 2013 13:36:55 +0400 Subject: [PATCH] FreeBSD group operations is now supported properly. --- system/group | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/system/group b/system/group index caa4d417c06..eb93d93c2d6 100644 --- a/system/group +++ b/system/group @@ -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(