diff --git a/changelog/62377.fixed b/changelog/62377.fixed new file mode 100644 index 00000000000..1a4bef889cb --- /dev/null +++ b/changelog/62377.fixed @@ -0,0 +1 @@ +Fix groups with duplicate GIDs are not returned by get_group_list diff --git a/salt/modules/groupadd.py b/salt/modules/groupadd.py index cb325eea1b2..a18cc1df9bc 100644 --- a/salt/modules/groupadd.py +++ b/salt/modules/groupadd.py @@ -40,8 +40,10 @@ def __virtual__(): ) -def add(name, gid=None, system=False, root=None): +def add(name, gid=None, system=False, root=None, non_unique=False): """ + .. versionchanged:: 3006.0 + Add the specified group name @@ -56,6 +58,11 @@ def add(name, gid=None, system=False, root=None): root Directory to chroot into + non_unique + Allow creating groups with duplicate (non-unique) GIDs + + .. versionchanged:: 3006.0 + CLI Example: .. code-block:: bash @@ -67,6 +74,8 @@ def add(name, gid=None, system=False, root=None): cmd.append("-g {}".format(gid)) if system and __grains__["kernel"] != "OpenBSD": cmd.append("-r") + if non_unique: + cmd.append("-o") if root is not None: cmd.extend(("-R", root)) diff --git a/tests/support/pytest/helpers.py b/tests/support/pytest/helpers.py index 0b8cef7f33d..4b52e0cedad 100644 --- a/tests/support/pytest/helpers.py +++ b/tests/support/pytest/helpers.py @@ -214,7 +214,9 @@ class TestGroup: def __enter__(self): group = self.sminion.functions.group.info(self.name) if not group: - ret = self.sminion.functions.group.add(self.name, gid=self.gid) + ret = self.sminion.functions.group.add( + self.name, gid=self.gid, non_unique=True + ) assert ret self._delete_group = True log.debug("Created system group: %s", self)