Specify roles directory?

Hi All,

Maybe there is already a setting for this and I am just missing it…

With the ansible-playbook command line how do I specify the directory to use for the roles?

Right now I have things set up sort of like follows:

ourhosts.ini
ourvariables.yml
deploy_nyc.yml
deploy_ams.yml
deploy_sgp.yml

roles/
common/

webtier/
monitoring/
fooapp/

Inside each of our deploy_nyc.yml files we target different hosts with different roles etc. In order not to have to remember many of the details of each of the scripts we might turn around and have lots of these scripts. Eg

deploy_blogsite_nyc.yml
deploy_fullmonitoring_sgp.yml,
etc.

In that way we just tweak these scripts with the hosts and tags and roles etc we want… But to do this I would like to be able to have the structure:

ourhosts.ini
ourvariables.yml
deploy/
deploy_nyc.wml

deploy_ams.yml

deploy_sgp.yml

roles/
common/

webtier/
monitoring/
fooapp/

And then I would like to be able to open up a command line and go something like:

cd deploy
ansible-playbook --inventory-file=“…/outhosts.ini” --extra-vars=“…/ourvariables.yml” --roles-directory=“…/roles” deploy_nyc.yml

but --roles-directory doesn’t exist. Does some other thing exist to do this? If not is this a reasonable thing to add?

Thanks!
Jason

You can include roles from arbitrary paths by including the full path in
the role as follows:

roles:
  - { role: /path/to/my/role }
  - { role: /different/path/to/another/role }

etc.

When using the ansible-galaxy, it by default will save roles in the path
defined in your ansible.cfg by the variable "roles_path" (which defaults to
/etc/ansible/roles), however that is not used when the plabook looks up the
role.

There’s also a roles search path that’s configurable in ansible.cfg.

http://docs.ansible.com/intro_configuration.html#roles-path