Fix macos defaults (#79999)

pull/81556/head
Caesarovich 10 months ago committed by GitHub
parent 390e508d27
commit c69c83c962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- 'ansible_user_module - tweaked macos user defaults to reflect expected defaults (https://github.com/ansible/ansible/issues/44316)'

@ -28,6 +28,7 @@ options:
comment:
description:
- Optionally sets the description (aka I(GECOS)) of user account.
- On macOS, this defaults to the O(name) option.
type: str
hidden:
description:
@ -49,6 +50,7 @@ options:
group:
description:
- Optionally sets the user's primary group (takes a group name).
- On macOS, this defaults to V('staff')
type: str
groups:
description:
@ -2512,6 +2514,14 @@ class DarwinUser(User):
if rc != 0:
self.module.fail_json(msg='Cannot create user "%s".' % self.name, err=err, out=out, rc=rc)
# Make the Gecos (alias display name) default to username
if self.comment is None:
self.comment = self.name
# Make user group default to 'staff'
if self.group is None:
self.group = 'staff'
self._make_group_numerical()
if self.uid is None:
self.uid = str(self._get_next_uid(self.system))

@ -65,3 +65,15 @@
- "user_test1.results[2]['state'] == 'present'"
- "user_test1.results[3]['state'] == 'present'"
- "user_test1.results[4]['state'] == 'present'"
- name: register user informations
when: ansible_facts.system == 'Darwin'
command: dscl . -read /Users/ansibulluser
register: user_test2
- name: validate user defaults for MacOS
when: ansible_facts.system == 'Darwin'
assert:
that:
- "'RealName: ansibulluser' in user_test2.stdout_lines "
- "'PrimaryGroupID: 20' in user_test2.stdout_lines "

@ -10,4 +10,4 @@ status_command:
default_user_group:
openSUSE Leap: users
MacOSX: admin
MacOSX: staff

Loading…
Cancel
Save