Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,2 @@
bugfixes:
- fixed the issue of creating user directory using tilde(~) always reported "changed".(https://github.com/ansible/ansible/issues/82490)
5 changes: 3 additions & 2 deletions lib/ansible/modules/user.py
Expand Up @@ -74,7 +74,8 @@
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
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
yctomwang marked this conversation as resolved.
Show resolved Hide resolved
home:
description:
- Optionally set the user's home directory.
Expand Down Expand Up @@ -3115,7 +3116,7 @@ def main():
groups=dict(type='list', elements='str'),
comment=dict(type='str'),
home=dict(type='path'),
shell=dict(type='str'),
shell=dict(type='path'),
password=dict(type='str', no_log=True),
login_class=dict(type='str'),
password_expire_max=dict(type='int', no_log=False),
Expand Down
19 changes: 19 additions & 0 deletions test/integration/targets/user/tasks/test_create_user.yml
Expand Up @@ -77,3 +77,22 @@
that:
- "'RealName: ansibulluser' 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: doesnotmatter
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: doesnotmatter
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