Ansible Jinja2 filter error Rhel 7.4

521 views
Skip to first unread message

smitconsu...@gmail.com

unread,
Apr 9, 2018, 8:38:51 AM4/9/18
to Ansible Project
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:

- 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

Kai Stian Olstad

unread,
Apr 9, 2018, 9:11:09 AM4/9/18
to ansible...@googlegroups.com
On Monday, 9 April 2018 14.38.51 CEST smitconsu...@gmail.com wrote:
> 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.

Equalto was added in 2.8.


--
Kai Stian Olstad

Shahzad Malik

unread,
Apr 9, 2018, 6:03:05 PM4/9/18
to ansible...@googlegroups.com
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
--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5664000.Igbv7u9FxM%40x1.
For more options, visit https://groups.google.com/d/optout.

Matt Martz

unread,
Apr 9, 2018, 6:27:37 PM4/9/18
to ansible...@googlegroups.com
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.

On Mon, Apr 9, 2018 at 5:02 PM, Shahzad Malik <maliksha...@gmail.com> wrote:
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


On Monday, April 9, 2018, Kai Stian Olstad <ansible-project+list@olstad.com> wrote:
On Monday, 9 April 2018 14.38.51 CEST smitconsu...@gmail.com wrote:
> 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.

Equalto was added in 2.8.


--
Kai Stian Olstad

--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAA1HA3ivVQA6UKOR_mV%2BPnDAmyb%2B_tb5AK7ArgjhgoCXrRtDjA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages