LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

How do you decide between import_* and include_* for a task file?

Import when the content is fixed and you want it visible in advance. Include when something only known at run time has to decide it: a loop, a condition checked once, a per-host file name.

Need Import Include
Loop over the file no yes
when checked once for the whole file no, copied to every task yes
File name from an inventory variable or fact no yes
Tasks shown by --list-tasks / --list-tags yes no
--start-at-task into the file yes no
Notify a single handler from the file yes no, only the whole include
Keywords such as tags reach the tasks yes, inherited only with apply:
Speed and overhead lean, done once more bookkeeping at run time

Everything in the table follows from one idea: an import is resolved before the run, an include during it. The Ansible docs also recommend sticking to one style per playbook where possible, because mixing static and dynamic reuse can lead to bugs that are hard to track down.

Go deeper:

From Quiz: ITIA / Ansible: Complex Playbooks with Imports and Includes | Updated: Dec 01, 2026