Simple task breaks with version 2.0.2.0

104 views
Skip to first unread message

Jürgen Haas

unread,
Apr 20, 2016, 10:32:35 AM4/20/16
to Ansible Project
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?

Brian Coca

unread,
Apr 20, 2016, 12:09:26 PM4/20/16
to ansible...@googlegroups.com
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)


----------
Brian Coca

Jürgen Haas

unread,
Apr 21, 2016, 2:50:43 AM4/21/16
to Ansible Project
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 %}"}



Jürgen Haas

unread,
Apr 21, 2016, 3:16:17 AM4/21/16
to Ansible Project
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.

Jürgen Haas

unread,
Apr 25, 2016, 2:21:30 AM4/25/16
to Ansible Project
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?

Jürgen Haas

unread,
Apr 25, 2016, 5:43:53 AM4/25/16
to Ansible Project
Also reported this in the issue queue: https://github.com/ansible/ansible/issues/15572

Looks like there is a broader issue.
Reply all
Reply to author
Forward
0 new messages