Chapter 2. Going Modular with Ansible Roles

In the last chapter, you learned about writing a simple playbook with Ansible. You also learned about the concepts of plays which map hosts to tasks. Writing tasks in a single playbook may work fine for a very simple setup. However, if we have multiple applications spanning across number of hosts, this will quickly become unmanageable.

In this chapter, you will be introduced to the following concepts:

  • What makes a role and what are roles used for?
  • How to create roles to provide abstraction?
  • Organizing content to provide modularity
  • Using include statements
  • Writing simple tasks and handlers
  • Installing packages, managing services, and serving files with Ansible modules

Understanding roles

In real-life scenarios, ...

Get Ansible Playbook Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.