LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

A main playbook first defines "Play 1" and then imports play2.yml. In which order does Ansible run them?

Top to bottom: Play 1 runs first, then the plays from play2.yml.

The main playbook lists Play 1 and an import of play2.yml; after parsing it becomes one flat list in which Play 1 is followed by the plays from play2.yml, and they run in that order

* After parsing, the import is replaced by the plays from the file, in place. *

- name: Play 1
  hosts: localhost
  tasks:
    - name: Display a message
      ansible.builtin.debug:
        msg: Play 1

- name: Import Playbook
  ansible.builtin.import_playbook: play2.yml

You can freely alternate plays written in the main file with imported playbooks. Because the import is static, Ansible replaces the import line with the plays from play2.yml while parsing, and the result is one flat list of plays that runs in order. Where the import sits is where its plays run.

Go deeper:

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