Skip to content

Instantly share code, notes, and snippets.

@neilus
Created September 9, 2019 20:20
Show Gist options
  • Save neilus/aa735b0cfea566ad30fcec2223d57fb3 to your computer and use it in GitHub Desktop.
Save neilus/aa735b0cfea566ad30fcec2223d57fb3 to your computer and use it in GitHub Desktop.
Comparing versions with ansible
---
- name: Comparing Semantic versions
hosts: localhost
tasks:
- name: a < b
assert:
that:
- "{{ item.a is version_compare(item.b, '<') }}"
with_items:
- a: "6.6.6"
b: "7.0"
- a: "6.5.10"
b: "6.6"
- name: not a < b
assert:
that:
- "{{ item.a is not version_compare(item.b, '<') }}"
with_items:
- a: "7.0"
b: "6.9"
- a: "7.0.0"
b: "6.9.10"
- a: "6.7.6"
b: "6.6.7"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment