LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

What does ansible.builtin.import_playbook do, and where in a playbook may it appear?

It pulls a whole other playbook (its list of plays) into a main playbook. It may only stand at the top level, as an entry in the list of plays, never inside a play.

- name: Prepare the web server
  ansible.builtin.import_playbook: web.yml

- name: Prepare the database server
  ansible.builtin.import_playbook: db.yml

The imported files are complete playbooks: each contains plays with their own hosts:, tasks: and so on. That is why the import must sit where plays sit. A play's tasks: list can hold tasks, not plays, so putting import_playbook under tasks: is an error.

The imported playbooks run in the order they are listed, as if their plays had been written directly into the main file. This makes a "site" playbook possible that sets up a whole environment by combining small, focused playbooks.

Go deeper:

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