Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-galaxy does not install versions with "+" (build metadata) by default #2137

Closed
ktdreyer opened this issue Dec 6, 2019 · 4 comments
Closed

Comments

@ktdreyer
Copy link

ktdreyer commented Dec 6, 2019

Bug Report

SUMMARY

I've uploaded Git snapshots of my collection to Ansible Galaxy. I'm using the + sign in my version number as described in the semver documentation.

My galaxy.yml looks like this:

namespace: ktdreyer
name: koji_ansible
version: "0.0.159+git.eb835b03"
# ...

I cannot install this, version, though, unless I specify the version number on the command-line.

STEPS TO REPRODUCE
  1. Upload a brand new collection to Galaxy with a version number that uses a "+" sign. For example: 0.0.159+git.eb835b03
  2. Try to install the new collection with ansible-galaxy on the command-line.
EXPECTED RESULTS

I should be able to install this version with ansible-galaxy collection install ktdreyer.koji_ansible, without specifying a version number.

ACTUAL RESULTS
$ ansible-galaxy collection install ktdreyer.koji_ansible
Process install dependency map
ERROR! Cannot meet requirement * for dependency ktdreyer.koji_ansible from source 'https://galaxy.ansible.com/api/'. Available versions before last requirement added: 
Requirements from:
	base - 'ktdreyer.koji_ansible:*'
@ktdreyer
Copy link
Author

ktdreyer commented Dec 6, 2019

This filtering is happening on the client. From ansible/galaxy/collection.py

from distutils.version import LooseVersion, StrictVersion

...

resp = api.get_collection_versions(namespace, name)

# Galaxy supports semver but ansible-galaxy does not. We ignore any versions that don't match
# StrictVersion (x.y.z) and only support pre-releases if an explicit version was set (done above).
versions = [v for v in resp if StrictVersion.version_re.match(v)]

On python3-libs-3.7.5-1.fc30, the StrictVersion.version_re regex is:

re.compile('^(\\d+) \\. (\\d+) (\\. (\\d+))? ([ab](\\d+))?$', re.VERBOSE|re.ASCII)

@ktdreyer
Copy link
Author

ktdreyer commented Dec 6, 2019

I think this means I would have to use version numbers like 0.0.0a159 to be compatible with distutils.version.StrictVersion.

@ktdreyer
Copy link
Author

ktdreyer commented Dec 7, 2019

Yeah, the Galaxy server does not accept a version string of 0.0.0a159.

ERROR! Error when publishing collection to default (https://galaxy.ansible.com/api/) (HTTP Code: 400, Message: Invalid version string: '0.0.0a159' Code: invalid)

@ktdreyer
Copy link
Author

ktdreyer commented Dec 9, 2019

I found ansible/ansible#64905 that provides more information about this.

The reason that the ansible-galaxy client does not use distutils.version.StrictVersion is because they would have to add a new dependency on https://pypi.org/project/semantic-version/ .

I will continue the discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant