community.general.collection_version lookup – Retrieves the version of an installed collection
Note
This lookup plugin is part of the community.general collection (version 6.6.2).
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
Synopsis
This lookup allows to query the version of an installed collection, and to determine whether a collection is installed at all.
By default it returns
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 itsgalaxy.yml
. This behavior can be adjusted by providing other values with result_not_found and result_no_version.
Terms
Parameter |
Comments |
---|---|
The collections to look for. For example |
Parameters
Parameter |
Comments |
---|---|
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: |
|
The value to return when the collection could not be found. By default, |
Examples
- name: Check version of community.general
ansible.builtin.debug:
msg: "community.general version {{ lookup('community.general.collection_version', 'community.general') }}"
Return Value
Key |
Description |
---|---|
The version number of the collections listed as input. If a collection can not be found, it will return the value provided in result_not_found. By default, this is If a collection can be found, but the version not identified, it will return the value provided in result_no_version. By default, this is Returned: success |
Collection links
Issue Tracker Repository (Sources) Submit a bug report Request a feature Communication