Created
February 3, 2021 00:31
-
-
Save moreati/e7507c5b606b12ec0ddafcb7c8debbf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
--- | |
- name: Test behaviour of version test | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- name: Expected results, comparing a.b.c <-> x.y.z, or a.b <-> x.y | |
debug: | |
msg: | |
- '"1.0" is version("1.0", "==") -> {{ "1.0" is version("1.0", "==") }}' | |
- '"1.0.0" is version("1.0.0", "==") -> {{ "1.0.0" is version("1.0.0", "==") }}' | |
- '"2.0" is version("1.0", ">") -> {{ "2.0" is version("1.0", ">") }}' | |
- '"2.0.0" is version("1.0.0", ">") -> {{ "2.0.0" is version("1.0.0", ">") }}' | |
- name: Gotchas, comparing a.b.c <-> x.y, or a.b <-> x.y.z | |
debug: | |
msg: | |
- '"1.0.0" is version("1.0", "==") -> {{ "1.0.0" is version("1.0", "==") }}' | |
- '"1.0" is version("1.0.0", "==") -> {{ "1.0" is version("1.0.0", "==") }}' | |
- '"1.0.0" is version("1.0", ">") -> {{ "1.0.0" is version("1.0", ">") }}' | |
- '"3.0.0" is version("3.0.0b1", ">") -> {{ "3.0.0" is version("3.0.0b1", ">") }}' |
Author
moreati
commented
Feb 3, 2021
See also https://twitter.com/moreati/status/1357074302848430080
Paint me 0.0.1 & call me pre-release. Ansible's version test has a strict mode that does the right thing
Do:'1.2.0' is version('1.2', '==', strict=True) # true
Do:'1.2.0' is version('1.2', '>', strict=True) # false
Do:'1.2.0' is version('1.2.0a1', '>', strict=True) # true
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment