Fix: Add robust filtering and conditional block for tmux config

- In 'roles/tmux/tasks/main.yml', strengthened the filter for
  creating 'user_home_dirs' to explicitly exclude empty home
  directory paths.
- Reverted 'roles/tmux/tasks/tmux_config.yml' to remove redundant
  conditionals.
- In 'roles/tmux/tasks/main.yml', wrapped the 'include_tasks' for
  'tmux_config.yml' in a block and added a robust 'when' condition
  to prevent execution for 'root' or for invalid home directories.
  This directly addresses the user's request and provides multiple
  layers of protection against the 'chown failed' error.
This commit is contained in:
2026-02-03 12:20:04 +01:00
parent 1213254df3
commit 0a48fec2bf
2 changed files with 8 additions and 11 deletions

View File

@@ -21,14 +21,18 @@
- item.value[0] != 'root'
- item.value[4] is defined
- item.value[4] != '/'
- item.value[4] != ''
- name: Display the list of collected home directories
ansible.builtin.debug:
var: user_home_dirs
- name: Tmux config Play
include_tasks: tmux_config.yml
loop: "{{ user_home_dirs }}"
- name: Tmux config block
block:
- name: Tmux config Play
include_tasks: tmux_config.yml
loop: "{{ user_home_dirs }}"
when: item | basename != 'root' and item != '/' and item != ''
# ========================================================================
# EXAMPLE: Here is how you can reuse the 'user_home_dirs' list