# Ansible Jinja2 filter error Rhel 7.4

**URL:** <https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [April 9, 2018, 12:38pm UTC](https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226 "2018-04-09T12:38:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smitconsultant2017](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@smitconsultant2017](https://forum.ansible.com/u/smitconsultant2017)\
**Post date:** [April 9, 2018, 12:38pm UTC](https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226/1 "2018-04-09T12:38:51Z")

</div>

Hi

I am trying to run below playbook to find the server (openstack host), on which vm will be running using jinja2 filter but getting error no test named ‘equalto’. After googling found some ppl suggested upgrade jinja2 and I am using version 2.7 on RHEL which is latest for RHEL. I was able to somehow make this playbook work once but not sure how which proved that code is working. I am struggling since then but have no luck yet. I found compatibility issue on bugzilla between this jinja2 ver and ansible/ansible Tower? Can Anyone suggest what other filter or way I can choose to achieve this which works on below jinja2 version? Thanks

Playbook:

```auto
- hosts: localhost
  vars:
   openstack: [reg1, reg2, reg3, reg4]

  tasks:
- name: Command to find os server where vm exists
  shell: somecommand-to-check-if-vm-exist | wc -l
  delegate_to: "{{ item }}"
  with_items: "{{ openstack }}"
  register: vm_check

- name: set fact
  set_fact:
    os_server: "{{ (vm_check.results | selectattr('stdout','equalto','1') | list | first }}"

- name: debug var
  debug:
    msg: "{{ os_server }}"

```

Error below:

“msg”: “Unexpected failure during module execution.”, “exception”: “Traceback File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 438, in call\_test\n raise TemplateRuntimeError(‘no test named %r’ % name)\nTemplateRuntimeError: no test named ‘equalto’\n”, “stdout”: “” }

## ansible --version ansible 2.4.3.0

ansible Tower ver: \< Tower 3.2.3 \>

python version = 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5

I am using RHEL 7.  
rpm -q python-jinja2  
python-jinja2-2.7.2-2.el7.noarch

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 9, 2018, 1:10pm UTC](https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226/2 "2018-04-09T13:10:52Z")

</div>

Equalto was added in 2.8.

---

<div class="post-metadata">

**Author:** ![Shahzad\_Malik](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Shahzad\_Malik](https://forum.ansible.com/u/Shahzad_Malik)\
**Post date:** [April 9, 2018, 10:02pm UTC](https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226/3 "2018-04-09T22:02:50Z")

</div>

Yes. Equalto was added in 2.8 and I can’t use this ver on RHEL at this stage. Is there other than equalto solution which I can use with 2.7 On RHEL 7.4? Thanks

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 9, 2018, 10:26pm UTC](https://forum.ansible.com/t/ansible-jinja2-filter-error-rhel-7-4/27226/4 "2018-04-09T22:26:34Z")

</div>

Use `search` or `match` instead of `equalto`. They are regex search tests. `search` matches anywhere within the string, `match` is bound to matching where a string starts with a value.
