O'Reilly logo

Ansible Configuration Management - Second Edition by Daniel Hall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Role metadata

Using role metadata allows us to specify that our role depends on other roles. For example, if the application you are deploying needs to send an e-mail, your role could depend on a Postfix role. This would mean that before the application is set up and installed, Postfix will be installed and set up.

The meta/main.yml file will look similar to the following code:

---
allow_duplicates: no
dependencies:
  - apache

The allow_duplicates line is set to no, which is the default. If you set this to no, Ansible will not run a role the second time, if it is included twice with the same arguments. If you set it to yes, it will repeat the role even if it has run before. You can leave it off instead of setting it to no.

Dependencies are specified ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required