@ -72,17 +72,19 @@ Installing Multiple Roles From Multiple Files
=============================================
=============================================
At a basic level, including requirements files allows you to break up bits of configuration policy into smaller files. Role includes pull in roles from other files.
At a basic level, including requirements files allows you to break up bits of configuration policy into smaller files. Role includes pull in roles from other files.
::
ansible-galaxy install -r requirements.yml
ansible-galaxy install -r requirements.yml
# from galaxy
Content of requirements.yml
::
# from github
- src: yatesr.timezone
- src: yatesr.timezone
- include: webserver.yml
- include: webserver.yml
Content of the webserver.yml file.
Content of the webserver.yml file.
::
# from github
# from github
- src: https://github.com/bennojoy/nginx
- src: https://github.com/bennojoy/nginx
@ -132,6 +134,28 @@ And here's an example showing some specific version downloads from multiple sour
As you can see in the above, there are a large amount of controls available
As you can see in the above, there are a large amount of controls available
to customize where roles can be pulled from, and what to save roles as.
to customize where roles can be pulled from, and what to save roles as.
You can also pull down multiple roles from a single source(just make sure that you have a meta/main.yml file at the root level).
::
meta\main.yml
common-role1\tasks\main.yml
common-role2\tasks\main.yml
For example, if the above common roles are published to a git repo, you can pull them down using:
You could then use these common roles in your plays
::
---
- hosts: webservers
roles:
- common-roles/common-role1
- common-roles/common-role2
Roles pulled from galaxy work as with other SCM sourced roles above. To download a role with dependencies, and automatically install those dependencies, the role must be uploaded to the Ansible Galaxy website.
Roles pulled from galaxy work as with other SCM sourced roles above. To download a role with dependencies, and automatically install those dependencies, the role must be uploaded to the Ansible Galaxy website.