I am trying to have a block in Ansible which will invoke multiple playbooks using include if a specific flag is set. I am trying to achieve something similar to below:
- hosts: localhost tasks: - block: - include: script1.yml - include: script2.yml - include: script3.yml when: flag|boolThis snippet throws an error stating ERROR! unexpected parameter type in action: <type 'bool'>
Thanks in advance!
1 Answer
The plays can't be included in a block. Quoting from ansible.builtin.include Synopsis
Files with a list of plays can only be included at the top level.
As a result, only Play keywords can be applied. The condition when is not among them.