A group of tasks is used twice in a play, therefore they are placed in a separate file and invoked using ‘import_tasks’. However, the result is, in all variations I’ve tried:
TASK [linux-common : Include Xymon client configuration tasks] *************************************
fatal: [kapitein]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 192.168.0.110 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 0}
There are no problems with the (SSH) connection. The ansible server is running on Linux Mint 20.1, ansible version 2.9.6, python version 3.8.10. The playbook is:
---
- name: Jardinera configuration
hosts: Linux
roles:
- { role: linux-locale, when: "'Linux' in group_names" }
- { role: raspberry-pi-common, when: "'RaspberryPi' in group_names" }
- { role: vision-common, when: "'Vision' in group_names" }
- { role: linux-common, when: "'Linux' in group_names" }
- { role: linux-zram, when: "'Linux' in group_names" }
- { role: jardinera-common, when: "'Linux' in group_names" }
- import_playbook: playbook.kapitein.yaml
- import_playbook: playbook.plant0.yaml
The import_tasks is located in role linux-common. The relevant part of the tasks file in this role is:
- name: Include Xymon client configuration tasks
ansible.builtin.import_tasks:
file: "~/ansible/{{ jardinera_path }}tasks.xymon.client.yaml"
when: "'XymonProxy' in group_names or 'XymonServer' in group_names"
with variable ‘jardinera_path’ containing “jardinera/”. The start of file ‘tasks.xymon.client.yaml’ is:
---
- name: Add user xymon to groups adm and video
user:
name: xymon
groups: adm,video
append: true
when: "'Xymon' in group_names"
If the contents of file `tasks.xymon.client.yaml’ is included in the tasks section of the role, it just works.
What am I doing wrong?