Chapter 7. Ansible Roles and Collections

You have seen how to write playbooks to execute specific tasks throughout the book. For example, we have covered tasks such as copying files into managed servers, creating users, manipulating files, or installing packages (such as the Java Virtual Machine).

But, what happens when you need to reuse the same tasks through different projects?

Do you remember one of the first examples in the book, where we reviewed a complete playbook for deploying a Java service?

The steps included in the playbook covered:

  • Installing dependencies (JVM) on managed hosts.

  • Creating required directories.

  • Copying and configuring the application on managed hosts.

  • Configure supervisor.d to control the application.

As you can imagine, this process can be repeated for any Java project. How can you share this playbook among other projects so they don’t need to repeat the development of the same playbook over ...

Get Red Hat Certified Engineer (RHCE) Ansible Automation Study Guide 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.