Galaxy - Install Role from Subdirectory of Github Repo

3,875 views
Skip to first unread message

Nick Allen

unread,
Feb 25, 2016, 12:37:17 PM2/25/16
to Ansible Project

I have a Github repository that contains multiple roles, each in separate subdirectories.  For example, I have separate roles 'role-alpha' and 'role-beta' in a repo at https://github.com/whoami/project.git each located in subdirectories as follows.
  • provisioning/roles/role-alpha
  • provisioning/roles/role-beta

I am trying to install these roles via a 'requirements.yml' file by running the following.

ansible-galaxy install -r requirements.yml
 
Can I install roles from a single Github repository that have multiple roles, each in unique subdirectories?  What would the definition look like?

- name: role-alpha
  src
: https://github.com/whoami/project.git
 
???: provisioning/roles/role-alpha

Many thanks for any advice.

Chris Houseknecht

unread,
Feb 26, 2016, 8:44:35 AM2/26/16
to Ansible Project
The role installation process does not support this at present.  We're in the middle of re-thinking how role installs work. If you're interested, there is a proposal at github.com/ansible/ansible. Look in docs/proposals.

Combining multiple roles into a single repo makes things like testing, linting and versioning more complicated, so I don't know that we really want to add this support. However, you can always suggest it and see what the community thinks. 

--Chris 

Franklin Wise

unread,
Mar 19, 2016, 7:27:09 PM3/19/16
to Ansible Project
Chris - that makes sense. 

However, there's another use case where the support would be helpful. Which is keeping the ansible role in the same repo as the application it installs.  So if I have github.com/myuser/mycoolapi.git I might want to keep the ansible role in a folder within the same mycoolapi that way the role can be versioned with the code it installs.  Thoughts?

Franklin

Javier Palacios

unread,
Mar 21, 2016, 5:31:25 AM3/21/16
to ansible...@googlegroups.com

If you don't mind making a tarball with the roles, you can use https://github.com/javiplx/ansible-library/, which is basically a install only private galaxy server, from where you can serve your packaged roles (so, it doesn't matter the tree where they live).

Javier Palacios

On Fri, Mar 18, 2016 at 11:45 PM, Franklin Wise <frankl...@gmail.com> wrote:
However, there's another use case where the support would be helpful. Which is keeping the ansible role in the same repo as the application it installs.  So if I have github.com/myuser/mycoolapi.git I might want to keep the ansible role in a folder within the same mycoolapi that way the role can be versioned with the code it installs.  Thoughts?

Aneesh Joseph

unread,
Jul 24, 2016, 1:35:08 AM7/24/16
to Ansible Project
If you want to pull down the entire Git repo and use the different roles within in it, you just need to have a meta/main.yml file at the repo root. See https://github.com/ansible/ansible/issues/16804 for details
Reply all
Reply to author
Forward
0 new messages