l3ender / nexus-repository-ansiblegalaxy

A Nexus Repository 3 plugin that allows usage of Ansible Galaxy repositories.
30 stars 12 forks source link

Unable to install galaxy roles without version #22

Open v-slenter opened 1 year ago

v-slenter commented 1 year ago

When installing a ansible galaxy role, that has no versions, this plugin cannot be used to proxy those roles. For example role stuvusit.systemd-timesyncd is affected by this. The ansible-galaxy cli uses the url from the version information, to retrieve the role artefact and seems to fall back to download from the master branch from the github repository.

This does not work in environments where ansible-galaxy has no internet access and the install will fail with:

downloading role from https://github.com/stuvusIT/systemd-timesyncd/archive/master.tar.gz [ERROR]: failed to download the file: <urlopen error timed out>"

Example requirements.yaml that fails:

---
- src: stuvusit.systemd-timesyncd

This could be solved by injecting version master containing the correct download url when no version is avialable for a role. This would let ansible-galaxy retrieve the artifact via the Nexus server in this case and replicate the fallback behaviour of ansible-galaxy.

A working workaround is to use the Nexus dowload url as role src, for example:

---
- src: https://{nexus_url}/repository/{nexus_repo_name}/download/role/{github_user}/{github_repo}/archive/master.tar.gz?module={role_name}
  name: {role_name}

Note: setting name is required, so the artifact is placed in the correct location locally.

cc @DarthHater @bhamail @l3ender