↓ Skip to main content
Linux

Ansible: Structure of a playbook?

·1 min
An Ansible playbook made of inventory, variables, roles and tasks, beside a short example playbook
Recreated in October 2026 from the post; the original image was lost

The structure of an Ansible playbook includes the following elements:

  1. Inventory file: A list of hosts or systems that the playbook will be executed on.
  2. Variables: Values that can be reused across multiple tasks within the playbook.
  3. Roles: Reusable collections of tasks, files, and templates that can be used across multiple playbooks.
  4. Tasks: The individual actions to be performed on the systems specified in the inventory file.

When including a playbook in another playbook, it is important to structure the playbooks in a way that makes it easy to understand the flow of tasks and the relationships between playbooks. This can be achieved by organizing tasks into roles, grouping related playbooks together, and using clear and descriptive naming conventions for playbooks and roles.

Additionally, it is a best practice to use tags to label tasks and roles and selectively run only specific tasks or roles within a playbook. This allows for more flexible and efficient execution of playbooks.

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Ansible: Refresher

·5 mins
Recreated in October 2026 from the post; the original image was lost What is Ansible? # Ansible is an open-source software platform for automating and configuring computer systems. It allows you to manage, deploy and orchestrate applications, infrastructure, and network devices using a simple, human-readable language. Ansible uses a push-based architecture, where tasks are executed on remote hosts from a central control machine, and does not require agents to be installed on target systems.

Python: Using flask

·3 mins
Building a simple hello world using Flask. (The code is available here) What is Flask and why use it? # Flask is a lightweight web framework for Python, but there are certain cases when you may want to consider using an alternative. Here are some of the cases when you might not want to use Flask: