Specify roles directory?

6,244 views
Skip to first unread message

Jason Harris

unread,
May 23, 2014, 4:05:30 PM5/23/14
to ansible...@googlegroups.com
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

James Cammarata

unread,
May 23, 2014, 5:31:56 PM5/23/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9f277eae-31f4-4c39-ac6f-120940e5aecb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
May 25, 2014, 4:52:11 PM5/25/14
to ansible...@googlegroups.com
There's also a roles search path that's configurable in ansible.cfg.



Reply all
Reply to author
Forward
0 new messages