Note
This lookup plugin is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.collection_version.
New in community.general 4.0.0
none for non-existing collections and * for collections without a version number. The latter should only happen in development environments, or when installing a collection from git which has no version in its galaxy.yml. This behavior can be adjusted by providing other values with result_not_found and result_no_version.Parameter | Comments |
|---|---|
Terms list / elements=string / required | The collections to look for. For example |
This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following examples: lookup('community.general.collection_version', key1=value1, key2=value2, ...) and query('community.general.collection_version', key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
result_no_version string | The value to return when the collection has no version number. This can happen for collections installed from git which do not have a version number in By default, Default: |
result_not_found string | The value to return when the collection could not be found. By default, |
Note
lookup('community.general.collection_version', term1, term2, key1=value1, key2=value2) and query('community.general.collection_version', term1, term2, key1=value1, key2=value2)
- name: Check version of community.general
ansible.builtin.debug:
msg: "community.general version {{ lookup('community.general.collection_version', 'community.general') }}"
Key | Description |
|---|---|
Return value list / elements=string | The version number of the collections listed as input. If a collection can not be found, it will return the value provided in If a collection can be found, but the version not identified, it will return the value provided in Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/collection_version_lookup.html