group - fix explicit git scenario (#52769)

* group - fix explicit git scenario

* Use str for simplicity and remove changelog

* dynamically get gid and remove Jinja2 check
This commit is contained in:
Jordan Borean
2019-02-22 12:40:42 +10:00
committed by GitHub
parent 63c22f6eb0
commit aab1f30906
4 changed files with 220 additions and 99 deletions

View File

@@ -120,7 +120,7 @@ class Group(object):
for key in kwargs:
if key == 'gid' and kwargs[key] is not None:
cmd.append('-g')
cmd.append(kwargs[key])
cmd.append(str(kwargs[key]))
elif key == 'system' and kwargs[key] is True:
cmd.append('-r')
cmd.append(self.name)
@@ -137,7 +137,7 @@ class Group(object):
if key == 'gid':
if kwargs[key] is not None and info[2] != int(kwargs[key]):
cmd.append('-g')
cmd.append(kwargs[key])
cmd.append(str(kwargs[key]))
if len(cmd) == 1:
return (None, '', '')
if self.module.check_mode:
@@ -182,7 +182,7 @@ class SunOS(Group):
for key in kwargs:
if key == 'gid' and kwargs[key] is not None:
cmd.append('-g')
cmd.append(kwargs[key])
cmd.append(str(kwargs[key]))
cmd.append(self.name)
return self.execute_command(cmd)
@@ -211,7 +211,7 @@ class AIX(Group):
cmd = [self.module.get_bin_path('mkgroup', True)]
for key in kwargs:
if key == 'gid' and kwargs[key] is not None:
cmd.append('id=' + kwargs[key])
cmd.append('id=' + str(kwargs[key]))
elif key == 'system' and kwargs[key] is True:
cmd.append('-a')
cmd.append(self.name)
@@ -223,7 +223,7 @@ class AIX(Group):
for key in kwargs:
if key == 'gid':
if kwargs[key] is not None and info[2] != int(kwargs[key]):
cmd.append('id=' + kwargs[key])
cmd.append('id=' + str(kwargs[key]))
if len(cmd) == 1:
return (None, '', '')
if self.module.check_mode:
@@ -256,7 +256,7 @@ class FreeBsdGroup(Group):
cmd = [self.module.get_bin_path('pw', True), 'groupadd', self.name]
if self.gid is not None:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
return self.execute_command(cmd)
def group_mod(self, **kwargs):
@@ -265,7 +265,7 @@ class FreeBsdGroup(Group):
cmd_len = len(cmd)
if self.gid is not None and int(self.gid) != info[2]:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
# modify the group if cmd will do anything
if cmd_len != len(cmd):
if self.module.check_mode:
@@ -304,12 +304,12 @@ class DarwinGroup(Group):
cmd = [self.module.get_bin_path('dseditgroup', True)]
cmd += ['-o', 'create']
if self.gid is not None:
cmd += ['-i', self.gid]
cmd += ['-i', str(self.gid)]
elif 'system' in kwargs and kwargs['system'] is True:
gid = self.get_lowest_available_system_gid()
if gid is not False:
self.gid = str(gid)
cmd += ['-i', self.gid]
cmd += ['-i', str(self.gid)]
cmd += ['-L', self.name]
(rc, out, err) = self.execute_command(cmd)
return (rc, out, err)
@@ -327,7 +327,7 @@ class DarwinGroup(Group):
cmd = [self.module.get_bin_path('dseditgroup', True)]
cmd += ['-o', 'edit']
if gid is not None:
cmd += ['-i', gid]
cmd += ['-i', str(gid)]
cmd += ['-L', self.name]
(rc, out, err) = self.execute_command(cmd)
return (rc, out, err)
@@ -376,7 +376,7 @@ class OpenBsdGroup(Group):
cmd = [self.module.get_bin_path('groupadd', True)]
if self.gid is not None:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
cmd.append(self.name)
return self.execute_command(cmd)
@@ -385,7 +385,7 @@ class OpenBsdGroup(Group):
info = self.group_info()
if self.gid is not None and int(self.gid) != info[2]:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
if len(cmd) == 1:
return (None, '', '')
if self.module.check_mode:
@@ -418,7 +418,7 @@ class NetBsdGroup(Group):
cmd = [self.module.get_bin_path('groupadd', True)]
if self.gid is not None:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
cmd.append(self.name)
return self.execute_command(cmd)
@@ -427,7 +427,7 @@ class NetBsdGroup(Group):
info = self.group_info()
if self.gid is not None and int(self.gid) != info[2]:
cmd.append('-g')
cmd.append('%d' % int(self.gid))
cmd.append(str(self.gid))
if len(cmd) == 1:
return (None, '', '')
if self.module.check_mode: