-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add collection_version lookup #3633
Add collection_version lookup #3633
Conversation
bea326d
to
1bf4528
Compare
plugins/lookup/collection_version.py
Outdated
else: | ||
data = {} | ||
galaxy_path = os.path.join(path, 'galaxy.yml') | ||
galaxy_alt_path = os.path.join(path, 'galaxy.yaml') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, galaxy.yaml
was never a valid name for the collection metadata file (and git grep
through ansible/ansible seems to confirm my suspicions). Maybe we can remove this line and simplify the code a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true for ansible-core 2.12 and Ansible 2.9, but ansible-base 2.10 and ansible-core 2.11 did support galaxy.yaml. Support was removed in ansible/ansible@595413d (see the changes in lib/ansible/galaxy/collection/__init__.py
which are hidden by default). I'll add a comment to document that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documented in 1169b5a.
I can also remove this, or make this code only execute for 2.10 and 2.11. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! As discussed in IRC I hope this would make its way to core too: ansible/community#631 (comment)
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
@rndmh3ro @tadeboro @briantist @agaffney thanks for reviewing and discussing this (resp. earlier versions)! |
* Add collection_verison lookup plugin. * Document ansible-base 2.10 and ansible-core 2.11 special case. * Add default for result_not_found. * Simplify not existing test. * Move metadata loading to function. * Update plugins/lookup/collection_version.py Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com> * Extend tests. * Fix tests for ansible-core < 2.12. Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
SUMMARY
This lookup allows to query the version of a collection that's installed and loaded by the currently running Ansible version.
This can be useful in roles or playbooks that have to support a larger range of collection (or Ansible community package) versions, where backwards incompatible changes have been made, or where some operations can be optimized with new plugins/modules that are not available in all supported versions.
ISSUE TYPE
COMPONENT NAME
collection_version