Interview Prep/Ansible/Fundamentals and Architecture

In what order are the parts of a play executed?

IntermediateConceptFundamentals and Architecture
Answer

Within one play, in this order regardless of how they appear in the file:

  1. pre_tasks
  2. Handlers notified by pre_tasks
  3. roles (and tasks that import roles)
  4. tasks
  5. Handlers notified by roles/tasks
  6. post_tasks
  7. Handlers notified by post_tasks

Role dependencies in meta/main.yml run before the role that depends on them. Facts are gathered before everything, as an implicit first step.

All Ansible questions Roadmap: Ansible

More on Fundamentals and Architecture