Updated ansible failed on checks

27 views
Skip to first unread message

Chris Bidwell - NOAA Federal

unread,
Nov 14, 2019, 5:54:25 PM11/14/19
to ansible...@googlegroups.com
Hi all,

After running ansible 2.9, I'm getting these errors:

fatal: [jjohnson-lx]: FAILED! => {"msg": "The conditional check 'ansible_distribution_major_version | version_compare('6', '=')' failed. The error was: template error while templating string: no filter named 'version_compare'. String: {% if ansible_distribution_major_version | version_compare('6', '=') %} True {% else %} False {% endif %}\n\nThe error appears to be in '/zabbix.yml': line 76, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: \"install 6 if not exists (no proxy)\"\n      ^ here\n"}

Here is what's in that section:

name: "install 6 if not exists (no proxy)"
      yum:
        name: "{{ zabbix_6 }}"
        state: latest
      ignore_errors: true
      environment: "{{ proxy_env }}"
      when:
        - ansible_distribution_major_version | version_compare('6', '=')
        - zabbix_exists.stat.exists == False
        - proxy.stdout.find('proxy') == -1
      tags:
        - YUM

Matt Martz

unread,
Nov 14, 2019, 5:58:33 PM11/14/19
to ansible...@googlegroups.com
The syntax you are using was deprecated in Ansible 2.5 and should have been emitting a deprecation warning. See this doc for more info:


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAHKi8Chf5XnOLB%2BY3vKXwiHkGg5%3DRisF%3DXqqZGL6KPo%2BkFmgCg%40mail.gmail.com.
--
Matt Martz
@sivel
sivel.net

Vladimir Botka

unread,
Nov 15, 2019, 2:45:36 AM11/15/19
to Matt Martz, ansible...@googlegroups.com
On Thu, 14 Nov 2019 16:58:01 -0600
Matt Martz <ma...@sivel.net> wrote:

> The syntax you are using was deprecated in Ansible 2.5 and should have been
> emitting a deprecation warning. See this doc for more info:
> https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.5.html#jinja-tests-used-as-filters
> Effectively you need to change the `|` to `is`
> >
> > After running ansible 2.9, I'm getting these errors:
> > ... no filter named 'version_compare'...
> >
> > when:
> > - ansible_distribution_major_version | version_compare('6', '=')

In addition to changing the deprecated syntax use "version" instead of
"version_compare"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#version-comparison

(Just curious). It's not clear why 2.9 complains "no filter named
'version_compare'". Both names of the filter are present in 2.9 source
https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/plugins/test/core.py

# version comparison
'version_compare': version_compare,
'version': version_compare,

(lines 199-201)

, and I can't find any explanation in the "porting guides" and "release notes"
either.
https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html
https://docs.ansible.com/ansible/latest/porting_guides/

What am I missing ?

Thank you,

-vlado

Sam Doran

unread,
Nov 15, 2019, 11:29:55 AM11/15/19
to ansible...@googlegroups.com
Vlado,

You're not missing anything. The version_compare test still exists, is not deprecated, and is fine to use — just not as a filter.

We used to register tests as filters. Since we no longer do this, Jinja raises an error that version_compare is not a valid filter, which is accurate.

---

Sam

Vladimir Botka

unread,
Nov 15, 2019, 1:56:49 PM11/15/19
to Sam Doran, ansible...@googlegroups.com
> Sam

Sam,

thank you very much for the clarification!

For the record, quoting from *Ansible 2.9 "Immigrant Song" Release Notes*
https://github.com/ansible/ansible/blob/stable-2.9/changelogs/CHANGELOG-v2.9.rst#id2

* Jinja tests - Remove deprecated functionality of registering tests as
filters (https://github.com/ansible/ansible/issues/55319)

(This explains the error in 2.9: "no filter named 'version_compare'")

-vlado

Chris Bidwell - NOAA Federal

unread,
Nov 15, 2019, 2:37:44 PM11/15/19
to ansible...@googlegroups.com
Thanks all!  

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages