# Ansible Collection dependencies from internal git server?

**URL:** <https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053>\
**Category:** Get Help\
**Tags:** galaxy-ng\
**Created:** [December 11, 2024, 12:14pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053 "2024-12-11T12:14:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 12:14pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/1 "2024-12-11T12:14:09Z")

</div>

All, We would like to host internally-developed Ansible collections from our internal GitLab server. So when our internal integrators do this:

```auto
ansible-galaxy collection install\
  git@our.gitlab.server:foo/collection-a.git,some-branch

```

… then all the dependent collections and roles would also be installed from GitLab. I’ve tried several permutations in the `dependencies` key in `galaxy.yaml` with no luck. Is below - or something like it - supported in `galaxy.yml` `dependencies:`?

```auto
dependencies:
  'git@our.gitlab.server:foo/collection-b.git': '==this-branch'
  'git@our.gitlab.server:foo/collection-c.git': '==that-branch'

```

When I try I get:

```auto
[WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an unexpected error when getting available versions of collection foo.collection-b:
'/api/v3/plugin/ansible/content/published/collections/index/foo/collection-b/versions/'
ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/foo/collection-b/versions/'

```

Thanks for any insight.

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [December 11, 2024, 1:17pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/2 "2024-12-11T13:17:26Z")

</div>

Should just be:

```auto
dependencies:
  'git@our.gitlab.server:foo/collection-b.git': 'this-branch'
  'git@our.gitlab.server:foo/collection-c.git': 'that-branch'

```

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 1:21pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/3 "2024-12-11T13:21:40Z")

</div>

yep that was my first attempt - same result - to me the suspicious part is `/api/v3/plugin` - GitLab doesn’t support this endpoint to my knowledge. Before cracking open the Ansible code I thought I was see if others had already successfully done this.

---

<div class="post-metadata">

**Author:** ![jeffrey44113](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jeffrey44113](https://forum.ansible.com/u/jeffrey44113)\
**Post date:** [December 11, 2024, 1:39pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/4 "2024-12-11T13:39:43Z")

</div>

would a requirements.yml not be easier?

I setup something similar with AWX.  
Created a repo with with the collection name for example:  
test.collection

Created roles folder, plugins and so on.  
Then in a other repo with all the awx playbooks named for example:  
AWX Playbooks  
I have a requirements.yml with the following lines:

```auto
collections:
- name: git@gitlablocal.local:some-group/test.collection.git
  type: git
  version: master

```

But the requirements.yml you can just use also locally by installing it through

```auto
ansible-galaxy install -r requirements.yml

```

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 1:48pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/5 "2024-12-11T13:48:19Z")

</div>

It appears that using `requirements.yml` requires three steps:

1. `ansible galaxy collection install first-collection`
2. Go look for `requirements.yml` in the collection files
3. `ansible galaxy install -r "path to requirements"`

Avoiding steps \>=2 is the purpose of `dependencies` in `galaxy.yml` except it appears to me that Ansible didn’t envision having dependencies of a collection in gitlab - as listed in `galaxy.yml`.

Looking at [this link](https://docs.ansible.com/ansible/latest/community/collection_contributors/collection_requirements.html#coll-dependencies) it states the following:

> Collection dependencies MUST be published on Galaxy.

So this leads me to believe that it is not currently supported to have gitlab-hosted collection **dependencies** listed in `galaxy.yml`…

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [December 11, 2024, 1:52pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/6 "2024-12-11T13:52:24Z")

</div>

You can definitely do it with the galaxy.yml, and I think that is preferable if all of your dependencies are collections

Do you have a configuration for a galaxy server in your ansible.cfg?

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 1:54pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/7 "2024-12-11T13:54:14Z")

</div>

Well I think you’re saying it would require us to stand up an in-house Galaxy server which - definitely not opposed to but I was looking for the easy button for now to just host our roles and collections in GitLab…

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [December 11, 2024, 1:55pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/8 "2024-12-11T13:55:29Z")

</div>

If your referring to my post, I am not saying you need an in house galaxy server. Im wondering if you have an existing configuration thats messing with how ansible-galaxy is searching for your dependencies

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 1:58pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/9 "2024-12-11T13:58:34Z")

</div>

gotcha - I’m running the ansible-galaxy commands in a _bare_ test directory.

```auto
ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.7.16 (default, Oct 30 2024, 
20:44:12) [GCC 7.3.1 20180712 (Red Hat 7.3.1-17)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by 
setting deprecation_warnings=False in ansible.cfg.
ansible [core 2.11.12] 
  config file = None
  configured module search path = ['/home/redacted/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/redacted/.local/lib/python3.7/site-packages/ansible
  ansible collection location = /home/redacted/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/redacted/.local/bin/ansible
  python version = 3.7.16 (default, Oct 30 2024, 20:44:12) [GCC 7.3.1 20180712 (Red Hat 7.3.1-17)]
  jinja version = 3.0.0
  libyaml = True

```

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [December 11, 2024, 2:03pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/10 "2024-12-11T14:03:35Z")

</div>

if you use these dependencies, does it work?

```auto
dependencies:
  'git@github.com:ansible-collections/vmware.vmware.git': main

```

For a bare bones test, i made a directory with a galaxy.yml like

```auto
namespace: test
name: col
version: 1.0.0
readme: README.md
authors: []
description: Collection
license_file: LICENSE
tags: []
repository: ''
dependencies:
  'git@github.com:ansible-collections/vmware.vmware.git': main

```

and ran `ansible-galaxy collection install .`

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [December 11, 2024, 2:08pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/11 "2024-12-11T14:08:02Z")

</div>

I only learned this recently myself from this forum, but installing collections from a git repository is meant to be a “developer shortcut” per the official documentation: [Installing collections — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections_guide/collections_installing.html#installing-a-collection-from-a-git-repository)

> As a developer, installing from a git repository lets you review your collection before you create the tarball and publish the collection. As a user, installing from a git repository lets you use collections or versions that are not in Galaxy or Automation Hub yet. This functionality is meant as a minimal shortcut for developers of content as previously described, and git repositories may not support the full set of features from the `ansible-galaxy` CLI.

So it sorta occupies this vague space of “you can do it, but the better option would be to publish it somewhere”. Just food for thought if you are looking at setting up an on-prem Galaxy mirror (not a bad idea given the public Ansible galaxy has gone down twice this year).

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 2:19pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/12 "2024-12-11T14:19:54Z")

</div>

Interesting. I don’t have public keys in my GitHub account but this **does** work:

```auto
dependencies:
  'git+https://github.com/ansible-collections/vmware.vmware.git': main

```

So now it appears this is GitLab-related (at least our internal GitLab server maybe not GitLab itself).

At least I have something to go on here… Thanks.

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 2:20pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/13 "2024-12-11T14:20:55Z")

</div>

Yep - just looking for a low-impact way at present…

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [December 11, 2024, 2:28pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/14 "2024-12-11T14:28:33Z")

</div>

Sure thing. When I did use a private git server, we did used https with anonymous browsing enabled on the repo initially. Later, when we switched to ssh only, we needed to add the git servers public key to known hosts and setup an ssh key on the ansible controller so it could access the repo. It did work though

One of those _could_ be the issue and ansible-galaxy is just being quiet about it…  
Good luck, I hope it works out

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 2:30pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/15 "2024-12-11T14:30:05Z")

</div>

thanks - I appreciate the help.

---

<div class="post-metadata">

**Author:** ![eace](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@eace](https://forum.ansible.com/u/eace)\
**Post date:** [December 11, 2024, 4:08pm UTC](https://forum.ansible.com/t/ansible-collection-dependencies-from-internal-git-server/39053/16 "2024-12-11T16:08:16Z")

</div>

Update in case this helps anyone. [this GitHub issue](https://github.com/ansible/awx/issues/14495#issuecomment-1752708302) post from Oct '23 helped.

> The Ansible team released a new Galaxy server. You’d need to use Ansible \>=2.13.9 to download content from it.

Turns out a dependent collection of the one I was trying to install itself had deps on `amazon.aws` and my Ansible version (`core 2.11.12`) simply could not `ansible-galaxy collection install amazon.aws`. As soon as I added the ref to the “old” galaxy server to `ansible.cfg` then ansible-galaxy again started working but it looks like the old galaxy server isn’t 100% at parity with the new in terms of collection versions it maintains but - this seems to be the root cause for my particular situation.
