mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
FreeBSD group operations is now supported properly.
This commit is contained in:
parent
e075607c9b
commit
dcb22d1760
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():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
|
|
Loading…
Reference in a new issue