ansible / ansible.builtin / v2.15.10 / module / _include
Removed in 2.16
Reason:it has too many conflicting behaviours depending on keyword combinations and it was unclear how it should behave in each case. new actions were developed that were specific about each case and related behaviours. | Alternative:include_tasks, import_tasks, import_playbook
Include a task list
| "added in version" 0.6 of ansible.builtin"
Authors: Ansible Core Team (@ansible)
pip
Install with pip install ansible-core==2.15.10
Includes a file with a list of tasks to be executed in the current playbook.
Lists of tasks can only be included where tasks normally run (in play).
Before Ansible 2.0, all includes were 'static' and were executed when the play was compiled.
Static includes are not subject to most directives. For example, loops or conditionals are applied instead to each inherited task.
Since Ansible 2.0, task includes are dynamic and behave more like real tasks. This means they can be looped, skipped and use variables from any source. Ansible tries to auto detect this, but you can use the C(static) directive (which was added in Ansible 2.1) to bypass autodetection.
This module is also supported for Windows targets.
- hosts: all tasks: - ansible.builtin.debug: msg: task1 - name: Include task list in play ansible.builtin.include: stuff.yaml - ansible.builtin.debug: msg: task10
- hosts: all tasks: - ansible.builtin.debug: msg: task1 - name: Include task list in play only if the condition is true ansible.builtin.include: "{{ hostvar }}.yaml" static: no when: hostvar is defined
free-form: description: - This module allows you to specify the name of the file directly without any other options.