What happened to the old ansible.builtin.include module, and why was it replaced?
include was used for both playbooks and task files, and switched between static and dynamic behavior depending on context, which confused users and caused bugs. Ansible 2.4 split it into include_tasks, import_tasks and import_playbook; it was later deprecated and removed in ansible-core 2.16.
The old module had a messy history:
- Before 2.0 it worked as a static import.
- In 2.0 it became dynamic, which broke some playbooks and brought new limits.
- In 2.1 it could be static or dynamic, depending on task options. Whether a given
includewas static wasn't visible from the code, and it didn't work reliably in every context.
Ansible 2.4 introduced separate keywords whose behavior is clear from the name: import_* is always static, include_* is always dynamic. include was deprecated in ansible-core 2.12 and removed in 2.16, so on current versions an old playbook that still uses it fails. Replace it with include_tasks or import_tasks, and with import_playbook at play level.
Go deeper:
ansible-core 2.16 changelog (GitHub) — the entry that removes include in favour of include_tasks and import_tasks.
Includes and imports: dynamic and static reuse (official docs) — the two mechanisms side by side, in Ansible's own words.