diff options
author | James Cammarata <jcammarata@ansibleworks.com> | 2014-02-28 11:40:19 -0600 |
---|---|---|
committer | James Cammarata <jcammarata@ansibleworks.com> | 2014-02-28 11:46:27 -0600 |
commit | 57486b268abd6ddc6898cc899e0355a0c17cf55c (patch) | |
tree | 8c8bc8e7ea53bd060cb8c979f3bb5a82cb4ab30c | |
parent | e798b558aacb0ea57417ee45fc170d4b8f2e507e (diff) | |
download | ansible-57486b268abd6ddc6898cc899e0355a0c17cf55c.tar.gz |
Use the no-user-groups option (-N) for useradd in the user module
If no group was specified, but a group by the same name as the user
exists, an error was raised in the situation where USERGROUPS_ENAB is
enabled in /etc/login.defs (which is the case for almost every major
linux distro). In this case, the user will be put in group 100 (which
is usually the "users" group on those same distros). This is currently
only done in the base class, as the issue may not exist on other
platforms like AIX or the BSDs.
Fixes #6210
-rw-r--r-- | library/system/user | 6 |
1 files changed, 6 insertions, 0 deletions
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() |