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

**URL:** <https://forum.ansible.com/t/template-error-while-templating-string-no-filter-named-failed/35067>\
**Category:** Ansible Project\
**Created:** [April 27, 2021, 1:23pm UTC](https://forum.ansible.com/t/template-error-while-templating-string-no-filter-named-failed/35067 "2021-04-27T13:23:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicola\_L](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nicola\_L](https://forum.ansible.com/u/Nicola_L)\
**Post date:** [April 27, 2021, 1:23pm UTC](https://forum.ansible.com/t/template-error-while-templating-string-no-filter-named-failed/35067/1 "2021-04-27T13:23:37Z")

</div>

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](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](https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_filters.html#filters-often-used-with-conditionals). 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

---

<div class="post-metadata">

**Author:** ![sdoran](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sdoran](https://forum.ansible.com/u/sdoran)\
**Post date:** [April 27, 2021, 1:48pm UTC](https://forum.ansible.com/t/template-error-while-templating-string-no-filter-named-failed/35067/2 "2021-04-27T13:48:15Z")

</div>

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/dev_guide/testing/sanity/no-tests-as-filters.html)  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_tests.html#test-syntax](https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#test-syntax)

---

<div class="post-metadata">

**Author:** ![Nicola\_L](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nicola\_L](https://forum.ansible.com/u/Nicola_L)\
**Post date:** [April 27, 2021, 1:52pm UTC](https://forum.ansible.com/t/template-error-while-templating-string-no-filter-named-failed/35067/3 "2021-04-27T13:52:24Z")

</div>

Hi Sam,  
thanks a lot for pointing that out.

thanks for your time,  
Nicola
