Quiz Entry - updated: 2026.11.26
What exactly does "static" mean for an import and "dynamic" for an include?
An import is expanded while the playbook is parsed, so it behaves as if the tasks had been pasted in. An include is just one task until the run reaches it; only then is the file read and its tasks added.
Running a playbook has two phases: Ansible first parses the whole playbook into a list of plays and tasks, then executes that list host by host.
* Imports are resolved in phase 1, includes in phase 2. *
- Import (static). During parsing, Ansible opens the imported file and puts its tasks in place of the import line. By the time execution starts, the import has disappeared: the play simply contains those tasks. Nothing that happens during the run can change what was imported.
- Include (dynamic). During parsing, the include stays a single task. When execution reaches it, Ansible evaluates it like any other task (its
when, itsloop, its variables for this host), then reads the file and runs the tasks in it. So the result of earlier tasks can decide whether and how the file is included.
A good mental model: import = copy-paste before the run; include = a function call during the run.
Go deeper:
Includes and imports: dynamic and static reuse (official docs) — the two mechanisms side by side, in Ansible's own words.
Includes: dynamic reuse (official docs) — why included tasks can react to the results of earlier tasks.