template error while templating string: no filter named 'failed'

Hi all!

I’m having an issue while running the task at line 14 of this role:

https://github.com/nicolimo86/ansible-go/blob/master/tasks/main.yml

The error is the following:
TASK [ansible-go : Remove old installation of Go] ******************************
fatal: [ubuntu1804]: FAILED! => {“msg”: “The conditional check ‘go_version|failed or go_version.stdout != go_version_target’ failed. The error was: template error while templating string: no filter named ‘failed’. String: {% if go_version|failed or go_version.stdout != go_version_target %} True {% else %} False {% endif %}\n\nThe error appears to be in ‘/home/vagrant/.cache/molecule/ansible/default/roles/ansible-go/tasks/main.yml’: line 14, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Remove old installation of Go\n ^ here\n”}

I see the filter “failed” documented in Jinja2 here. Why is it not working?

MY ENV:
ansible --version
ansible 2.10.7
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/vagrant/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /home/vagrant/venv_automation/lib/python3.6/site-packages/ansible
executable location = /home/vagrant/venv_automation/bin/ansible
python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]

Nicola

Nicola,

Using tests as filters was deprecated in Ansible 2.5 and removed in 2.9.

https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/no-tests-as-filters.html
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#test-syntax

Hi Sam,
thanks a lot for pointing that out.

thanks for your time,
Nicola