Files
ansible-role-unix-users/tasks/copy_skel_file.yaml
T
volker.raschekandCopilot 517d9c1c54 refactor(tasks): prefix the home directory fact with the role name
`set_fact` writes into the play scope, so `user_user_home` outlived the loop iteration that set it and collided with any
playbook variable of the same name. Worse, if the defining task were ever skipped, every following task would silently
operate on the home directory of the previously processed user.

Renaming it to `_unix_users_home` marks it as role internal and matches the underscore prefix already used by the other
internal facts in this role. Purely mechanical, no behaviour changes.

Co-authored-by: Copilot <copilot@github.com>
2026-09-09 21:39:42 +02:00

19 lines
597 B
YAML

---
- name: "Check if the skel file exists: /etc/skel/{{ skel_file }}"
ansible.builtin.stat:
path: "/etc/skel/{{ skel_file }}"
register: _unix_users_skel_file
# force: false keeps an already customized dotfile in the home directory untouched.
- name: "Copy skel file: {{ skel_file }}"
ansible.builtin.copy:
src: "/etc/skel/{{ skel_file }}"
dest: "{{ _unix_users_home }}/{{ skel_file }}"
remote_src: true
force: false
owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}"
mode: "0644"
when: _unix_users_skel_file.stat.exists