Version warnings wrt Collections vs. Ansible

I’ve been studiously ignoring recent messages like this one:

[WARNING]: Collection community.vmware does not support Ansible version 2.14.7

until a couple of days ago, thinking that the older community.vmware collection that was getting pulled in was a bit long in the tooth and needed upgrading.

Then I changed the relevant collections/requirements.yml to pull in the latest community.vmware to address the problem, and I still got the same message. It wasn’t until then that I realized how ambiguous that message is.

It isn’t because the collection is to old. It’s because my Ansible is too old. D’oh!

A much better message would be:

[WARNING]: Collection A.B version I.J.K requires Ansible version L.M.N or higher

or maybe

[WARNING]: Collection A.B version I.J.K does not support Ansible versions below L.M.N

either of which would tell the user what the issue is rather than merely stating that there’s an issue relating to versions.

You should open a github issue with the collection.

The message is coming from ansible/plugins/loader.py.

(venv-python39-ansible-core-214) [utoddl@ssh site-packages]$ pwd
/opt/venv-python39-ansible-core-214/lib/python3.9/site-packages
(venv-python39-ansible-core-214) [utoddl@ssh site-packages]$ grep -rn 'does not support Ansible version' .
./ansible/plugins/loader.py:1425:            message = 'Collection {0} does not support Ansible version {1}'.format(collection_name, ansible_version)

Ah, I should raise the issue in Issues · ansible/ansible · GitHub. I erroneously thought it was one of the project that didn’t have issues any more. Mondays, right?

The problems with these messages is that they only work if requires_ansible in the collection’s meta/runtime.yml is of the form >=L.M.N, while that string can be a lot more complex (for example >1.2.3,<4.0.0-a,!=2.0.1,!=2.1.3,!=3.1.5,!=5.0.0).

Though having a special case for >=L.M.N, and printing the whole requirements string if it’s not of that form with a different message (like Collection A.B version I.J.K does not support Ansible version L.M.N; this version of the collection needs Ansible version <version-string-here>).

2 Likes