I need to dynamically install apt packages when the full Ubuntu version (Major.Minor like 18.10) is larger or smaller than a specified value. This is required to install the corrent libvirt-bin
package, that were renamed in 18.10. The fact ansible_distribution_version
holds the numeric version and I found the version comparision filter in an old Ansible doc, that seems renamed in Ansible 2.5 but it doesn't work in the latest 2.9 release:
- name: Execute on ubuntu 18.10 or newer
shell: "echo Youre on Ubuntu 18.10 or newer"
when: ansible_distribution_version | version('18.10', '>=')
The conditional check 'ansible_distribution_version | version('19.10', '>=')' failed. The error was: template error while templating string: no filter named 'version'.
The latest (currently 2.9) documentation doesn't contain any filter for version comparisation. I tried float-conversation, which seems to work:
- name: Execute on ubuntu 18.10 or newer
shell: "echo executed on ubuntu 18.10 or newer"
when: ansible_distribution_version | float >= 18.10
Are there any disadvantages of using this conversation that justifys why version_comparisation
and version
filters were introduced? Or is there another filter to safely compare versions that I haven't found?