community / community.general / 8.5.0 / lookup / collection_version Retrieves the version of an installed collection | "added in version" 4.0.0 of community.general" Authors: Felix Fontein (@felixfontein)community.general.collection_version (8.5.0) — lookup
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
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 V(none) for non-existing collections and V(*) 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 C(galaxy.yml). This behavior can be adjusted by providing other values with O(result_not_found) and O(result_no_version).
- name: Check version of community.general ansible.builtin.debug: msg: "community.general version {{ lookup('community.general.collection_version', 'community.general') }}"
_terms: description: - The collections to look for. - For example V(community.general). elements: str required: true type: list result_not_found: default: null description: - The value to return when the collection could not be found. - By default, V(none) is returned. type: string result_no_version: default: '*' description: - 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 C(galaxy.yml). - By default, V(*) is returned. type: string
_raw: description: - The version number of the collections listed as input. - If a collection can not be found, it will return the value provided in O(result_not_found). By default, this is V(none). - If a collection can be found, but the version not identified, it will return the value provided in O(result_no_version). By default, this is V(*). This can happen for collections installed from git which do not have a version number in V(galaxy.yml). elements: str type: list