The task is this:
`
- name: "Check Ansible version"
run_once: true
debug: msg="You need at least version 2.0.0.0, currently using version {{ ansible_version.full }}"
failed_when: "{{ ansible_version.full | version_compare('2.0.0.0', operator='lt', strict=False)}}"
`
The error message doesn’t ring a bell, it worked in 2.0.1.0:
The conditional check '{{ ansible_version.full|version_compare(\"2.0.0.0\" ' failed. The error was: template error while templating string: unexpected end of template, expected ','.. String: {{ ansible_version.full|version_compare(\"2.0.0.0\" "}
Any idea what’s wrong with it?
First always use moustaches except when when:
, you are stringifying/templating/stringifying/templating, this can lead to unexpected errors, just write it this way:
failed_when: ansible_version.full | version_compare(‘2.0.0.0’, operator=‘lt’, strict=False)
Well, when I do
failed_when: ansible_version.full | version_compare('2.0.0.0', operator='lt', strict=False)
I'll get this error:
The error was: template error while templating string: unexpected '}', expected ')'. String: {% if ansible_version.full|version_compare('2.0.0.0' %} True {% else %} False {% endif %}"}
Also, I’d suggest to update the documentation at http://docs.ansible.com/ansible/playbooks_filters.html#version-comparison-filters about this too, because this is where I got it from.
Has anyone else had this issue as well? Looks to be that version_compare() is completely broken. @Brian, what about the follow up issue when removing some of the wrappers like suggested?
Also reported this in the issue queue: https://github.com/ansible/ansible/issues/15572
Looks like there is a broader issue.