community.general.version_sort filter – Sort a list according to version order instead of pure alphabetical one
Note
This filter plugin is part of the community.general collection (version 9.3.0).
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.version_sort
.
New in community.general 2.2.0
Synopsis
Sort a list according to version order instead of pure alphabetical one.
Input
This describes the input of the filter, the value before | community.general.version_sort
.
Parameter |
Comments |
---|---|
A list of strings to sort. |
Examples
- name: Convert list of tuples into dictionary
ansible.builtin.set_fact:
dictionary: "{{ ['2.1', '2.10', '2.9'] | community.general.version_sort }}"
# Result is ['2.1', '2.9', '2.10']
Return Value
Key |
Description |
---|---|
The list of strings sorted by version. Returned: success |