diff options
author | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2014-08-28 23:24:32 +0200 |
---|---|---|
committer | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2015-02-13 10:14:37 +0100 |
commit | 67ce4cf416b6b1f21c0d28523e512851a28c1733 (patch) | |
tree | 52e378137b89c26a72879014d2e3d8dc881240f5 | |
parent | 1555cfeea236863572c8f9050804866eeddad9a7 (diff) | |
download | ansible-modules-core-67ce4cf416b6b1f21c0d28523e512851a28c1733.tar.gz |
Add basic support for OSX groups.
-rwxr-xr-x[-rw-r--r--] | system/group.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/system/group.py b/system/group.py index 617de7c2..83ea410b 100644..100755 --- a/system/group.py +++ b/system/group.py @@ -251,6 +251,49 @@ class FreeBsdGroup(Group): # =========================================== + + +class DarwinGroup(Group): + """ + This is a Mac OS X Darwin Group manipulation class. + + This overrides the following methods from the generic class:- + - group_del() + - group_add() + - group_mod() + + group manupulation are done using dseditgroup(1). + """ + + platform = 'Darwin' + distribution = None + + def group_add(self, **kwargs): + cmd = [self.module.get_bin_path('dseditgroup', True)] + cmd += [ '-o', 'create' ] + cmd += [ '-i', self.gid ] + cmd += [ '-L', self.name ] + (rc, out, err) = self.execute_command(cmd) + return (rc, out, err) + + def group_del(self): + cmd = [self.module.get_bin_path('dseditgroup', True)] + cmd += [ '-o', 'delete' ] + cmd += [ '-L', self.name ] + (rc, out, err) = self.execute_command(cmd) + return (rc, out, err) + + def group_mod(self): + info = self.group_info() + if self.gid is not None and int(self.gid) != info[2]: + cmd = [self.module.get_bin_path('dseditgroup', True)] + cmd += [ '-o', 'edit' ] + cmd += [ '-i', self.gid ] + cmd += [ '-L', self.name ] + (rc, out, err) = self.execute_command(cmd) + return (rc, out, err) + return (None, '', '') + class OpenBsdGroup(Group): """ This is a OpenBSD Group manipulation class. |