Ansible Collections - Handling a Dependent Collection that is only available via SCM

Hi Ansible Community :slightly_smiling_face:

In my collection I have a playbook which uses some modules from a different collection however, that collection is only published on GitHub and is not published on Ansible Galaxy.

How can I declare in my collection that this other dependent collection is required? AFAIK, in my collection’s galaxy.yml file it only supports installing dependent collections that are available via Ansible Galaxy:

---
# galaxy.yml
...
dependencies:
  community.general: "x.x.x"
  # It's not possible to specify it here as a dependent collection, right?

I know that a user using my collection could have in their project’s requirements.yml file like:

---
collections:
  - name: my_namespace.my_collection
  - name: https://github.com/org/theotherdependentcollection.git
    type: git
    version: x.x.x

But it just seems a bit clunky. The end user of my collection has to handle this dependent collection themselves, and the niceties of ansible-galaxy collection install just installing all the dependent collections required by my collection is lost :frowning:

Any response is greatly appreciated, thanks all and have a great day.

Installing from git is a not a first-class collection installation method; it’s solely intended as a convenience during development. You should encourage the collection you depend on to actually publish releases. (If it’s private content, the intended solution is to run a private Galaxy-compatible server like Ansible Automation Hub or amanda.)

That being said, I’m pretty sure you can just put the collection name as the repository syntax expected by Galaxy (Installing collections — Ansible Community Documentation) and it will work.

3 Likes

I came here to say this. git is not intended to be a reliable or supported way to distribute collections, and they should be published properly.

1 Like

Hi both,

Thank you for your quick responses :+1:

I tried what you suggested @flowerysong and it works well. Thank you :slightly_smiling_face:

# galaxy.yml
---
dependencies:
  - git+https://github.com/vmware/ansible-for-nsxt.git: "master"