user - Use -n instead of -N for luseradd on all distros (#75042)

* Use -n instead of -N for luseradd on all distros

Co-authored-by: Chris James <git@etcet.net>
pull/78087/head
Chris James 4 years ago committed by GitHub
parent 44b5314174
commit ea351f0ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- user - fix creating a local user if the user group already exists (https://github.com/ansible/ansible/pull/75042)

@ -693,10 +693,14 @@ class User(object):
# exists with the same name as the user to prevent # exists with the same name as the user to prevent
# errors from useradd trying to create a group when # errors from useradd trying to create a group when
# USERGROUPS_ENAB is set in /etc/login.defs. # USERGROUPS_ENAB is set in /etc/login.defs.
if self.local:
# luseradd uses -n instead of -N
cmd.append('-n')
else:
if os.path.exists('/etc/redhat-release'): if os.path.exists('/etc/redhat-release'):
dist = distro.version() dist = distro.version()
major_release = int(dist.split('.')[0]) major_release = int(dist.split('.')[0])
if major_release <= 5 or self.local: if major_release <= 5:
cmd.append('-n') cmd.append('-n')
else: else:
cmd.append('-N') cmd.append('-N')

@ -86,6 +86,7 @@
- testgroup3 - testgroup3
- testgroup4 - testgroup4
- testgroup5 - testgroup5
- local_ansibulluser
tags: tags:
- user_test_local_mode - user_test_local_mode
@ -163,6 +164,7 @@
- testgroup3 - testgroup3
- testgroup4 - testgroup4
- testgroup5 - testgroup5
- local_ansibulluser
tags: tags:
- user_test_local_mode - user_test_local_mode

Loading…
Cancel
Save