A new feature we will be introducing in 1.3 (and available now on the devel branch on github) are role dependencies. This allows roles to include other roles, and should allow for greater re-use of stock roles.
To create dependencies, just add a meta/ directory to your role with a main.yml file. As an example, if we had a "drupal" role, then the meta/main.yml file might contain something like this:
---
dependencies:
- { role: php, memory_limit: "128M" }
- { role: web_server, http_port: 8080 }
- { role: memcache, listen_address: "0.0.0.0" }
It is possible for dependent roles to have their own dependencies. Continuing the example above, the web_server role could have dependencies on nginx, fastcgi, and varnish roles.
Note the variable passed in with the web_server role: http_port. That variable will be seen by any dependent roles too, so the nginx and varnish roles could use that variable in their configuration templates without having to set it themselves (or it will override the defaults stored in vars/main.yml for each role).
Dependent roles are executed before the role that requires them, so again continuing the example above, the order of execution would be:
php -> nginx -> fastcgi -> varnish -> web_server -> memcache -> drupal
Last but not least, you can use fully qualified paths for the role names just like with regular role includes, so dependent roles do not have to be in the same directory as the playbook that uses them. For example:
---
dependencies:
- { role: "/path/to/common/roles/nginx" }
The docs on the website have been updated to include this information as well:
If you have any questions, let us know here or on IRC.
Enjoy!
--
James Cammarata <jcamm...@ansibleworks.com>
Sr. Software Engineer, AnsibleWorks, Inc.
http://www.ansibleworks.com/