Update version check logic #28

Open
opened 2016-12-18 13:08:46 +01:00 by alanorth · 0 comments
alanorth commented 2016-12-18 13:08:46 +01:00 (Migrated from github.com)

Instead of doing comparison operations on strings we should be using Ansible's version_compare filter.

Before:

{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '16.04' %}

After:

{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('16.04', '>=') %}

This makes me wonder why it ever worked in the first place. Seems like it should have been undefined, or always true, or something else bizarre and unpredictable.

Instead of doing comparison operations on strings we should be using [Ansible's `version_compare` filter](https://docs.ansible.com/ansible/playbooks_tests.html). Before: ``` {% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '16.04' %} ``` After: ``` {% if ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('16.04', '>=') %} ``` This makes me wonder why it ever worked in the first place. Seems like it should have been undefined, or always true, or something else bizarre and unpredictable.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: alanorth/ansible-personal#28
No description provided.