version_sort – Sort a list according to version order instead of pure alphabetical one

Note

This filter plugin is part of the middleware_automation.common collection.

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 middleware_automation.common.

To use it in a playbook, specify: middleware_automation.common.version_sort.

New in middleware_automation.common 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 | middleware_automation.common.version_sort.

Parameter

Comments

Input

list / elements=string / required

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'] | middleware_automation.common.version_sort }}"
    # Result is ['2.1', '2.9', '2.10']

Return Value

Key

Description

Return value

list / elements=string

The list of strings sorted by version.

Returned: success

Authors

  • Eric L. (@ericzolf)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.