community.general.version_sort (8.5.0) — filter

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

| "added in version" 2.2.0 of community.general"

Authors: Eric L. (@ericzolf)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert list of tuples into dictionary
  ansible.builtin.set_fact:
    dictionary: "{{ ['2.1', '2.10', '2.9'] | community.general.version_sort }}"

Inputs

    
_input:
    description: A list of strings to sort.
    elements: string
    required: true
    type: list

Outputs

_value:
  description: The list of strings sorted by version.
  elements: string
  type: list