diff --git a/library/system/user b/library/system/user index 928044a79d..a6d3a0ec32 100644 --- a/library/system/user +++ b/library/system/user @@ -289,6 +289,12 @@ class User(object): self.module.fail_json(msg="Group %s does not exist" % self.group) cmd.append('-g') cmd.append(self.group) + elif self.group_exists(self.name): + # use the -N option (no user group) if a group already + # exists with the same name as the user to prevent + # errors from useradd trying to create a group when + # USERGROUPS_ENAB is set in /etc/login.defs. + cmd.append('-N') if self.groups is not None and len(self.groups): groups = self.get_groups_set()