I would like to use the following task in a playbook:
- include: "{{ prerequisites_file }}"
with_first_found:
- "prerequisites-{{ ansible_distribution }}.yml"
- "prerequisites-{{ ansible_os_family }}.yml"
loop_control:
loop_var: prerequisites_file
I would like it to just pass if no files matching the architecture were found.
When run as is, in such a case, it produces an error:
TASK [ansible-playbook : include] ***************************************
fatal: [ansible-playbook]: FAILED! => {"failed": true, "msg": "No file was found when using with_first_found. Use the 'skip: true' option to allow this task to be skipped if no files are found"}
I know I can add a dummy file at the end, but if I were to follow the advice, how am I supposed to add the skip: true
option here?
It's definitely not an argument of the include
module, it should be somehow bound to with_first_found
clause...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…