Ansible Galaxy roles install in to a specific directory?

StenW picture StenW · Mar 5, 2014 · Viewed 42k times · Source

So I figured I should start using Ansible Galaxy when possible, instead of writing my own roles. I just installed my first role and it was installed to /etc/local/ansible/roles (I am on OSX).

Now I wonder how you install this roles where I actually need it? Do I just copy the role to where I need it or is there an Ansible way of doing it?

Answer

Rico picture Rico · Mar 6, 2014

Yes, you would copy them according to a sample project structure:

site.yml
webservers.yml
fooservers.yml
kubernetes.yaml
roles/
   common/
     files/
     templates/
     tasks/
     handlers/
     vars/
     meta/
   webservers/
     files/
     templates/
     tasks/
     handlers/
     vars/
     meta/
   kubernetes/
     files/
     templates/
     tasks/
     handlers/
     vars/
     meta/

or you can just run ansible-galaxy with the -p ROLES_PATH or --roles-path=ROLES_PATH option to install it under /your/project/root

You can also use the /etc/local/ansible directory as your project root if you'd like to.

Additionally, you can get help by running the command ansible-galaxy install --help