user: createhome=no home=/no/such/dir (#60310)

Fixes #60307.

This bug was introduced in commit d2edf1d435
("User - Create parent directories if they do not exist in the specified
home path (#51043)") and did not make it into any releases.
This commit is contained in:
Marius Gedminas 2019-08-12 17:37:45 +03:00 committed by Sam Doran
parent 13403b3688
commit c71622b31a
2 changed files with 17 additions and 1 deletions

View file

@ -2901,7 +2901,7 @@ def main():
# that do not exist.
path_needs_parents = False
if user.home:
parent = os.path.basename(user.home)
parent = os.path.dirname(user.home)
if not os.path.isdir(parent):
path_needs_parents = True

View file

@ -197,6 +197,22 @@
state: absent
# https://github.com/ansible/ansible/issues/60307
# Make sure we can create a user when the home directory is missing
- name: Create user with home path that does not exist
user:
name: ansibulluser3
state: present
home: "{{ user_home_prefix[ansible_facts.system] }}/nosuchdir"
createhome: no
- name: Cleanup test account
user:
name: ansibulluser3
state: absent
remove: yes
## user check
- name: run existing user check tests