Fix Creating user directory using tilde always reports "changed" (#83113)

Fixes: #82490
pull/83553/head
MajesticMagikarpKing 5 months ago committed by GitHub
parent e5309ba29f
commit edce798713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- fixed the issue of creating user directory using tilde(~) always reported "changed".(https://github.com/ansible/ansible/issues/82490)

@ -74,7 +74,8 @@ options:
Since Ansible 2.5, the default shell for non-system users on macOS is V(/bin/bash). Since Ansible 2.5, the default shell for non-system users on macOS is V(/bin/bash).
- On other operating systems, the default shell is determined by the underlying tool - On other operating systems, the default shell is determined by the underlying tool
invoked by this module. See Notes for a per platform list of invoked tools. invoked by this module. See Notes for a per platform list of invoked tools.
type: str - From Ansible 2.18, the type is changed to I(path) from I(str).
type: path
home: home:
description: description:
- Optionally set the user's home directory. - Optionally set the user's home directory.
@ -3167,7 +3168,7 @@ def main():
groups=dict(type='list', elements='str'), groups=dict(type='list', elements='str'),
comment=dict(type='str'), comment=dict(type='str'),
home=dict(type='path'), home=dict(type='path'),
shell=dict(type='str'), shell=dict(type='path'),
password=dict(type='str', no_log=True), password=dict(type='str', no_log=True),
login_class=dict(type='str'), login_class=dict(type='str'),
password_expire_max=dict(type='int', no_log=False), password_expire_max=dict(type='int', no_log=False),

@ -77,3 +77,28 @@
that: that:
- "'RealName: ansibulluser' in user_test2.stdout_lines " - "'RealName: ansibulluser' in user_test2.stdout_lines "
- "'PrimaryGroupID: 20' in user_test2.stdout_lines " - "'PrimaryGroupID: 20' in user_test2.stdout_lines "
#https://github.com/ansible/ansible/issues/82490
- name: Create a new user with custom shell to test ~ expansion
user:
name: randomuserthomas
shell: ~/custom_shell
register: user_create_result
- name: Create a new user with custom shell to test ~ expansion second time should show ok not changed
user:
name: randomuserthomas
shell: ~/custom_shell
register: user_creation_result
- name: Assert that the user with a tilde in the shell path is created
assert:
that:
- user_creation_result is not changed
- user_create_result is changed
- name: remove the randomuserthomas user to clean up
user:
name: randomuserthomas
state: absent
force: true
Loading…
Cancel
Save