What version of Ansible added the json_query filter?

2,213 views
Skip to first unread message

Ben Watson

unread,
Dec 6, 2016, 10:33:59 AM12/6/16
to Ansible Project
I'm currently running Ansible 2.1.0 and get an error when trying to use the json_query filter.

Example

- name: Display filtered variable contents
  debug: var=item
  with_items: "{{ my_var | json_query('json.[*].percent')}}"

I get the following Ansible error when run on remote hosts

"template error while templating string: no filter named 'json_query'

I know this functionality relies on jmespath, and I do have a task defined to install jmespath via pip, like so (before the debug task above):

- name: Run pip to install jmespath
  raw: pip install jmespath
  become: true
  become_method: sudo

Thanks!

Ben

Matt Martz

unread,
Dec 6, 2016, 11:07:18 AM12/6/16
to ansible...@googlegroups.com
`json_query` was added in v2.2

--
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/2e468409-dfcd-4a1b-8cfe-604bab38cba2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Ben Watson

unread,
Dec 6, 2016, 11:31:07 AM12/6/16
to Ansible Project
Thanks!


On Tuesday, December 6, 2016 at 10:07:18 AM UTC-6, Matt Martz wrote:
`json_query` was added in v2.2
On Tue, Dec 6, 2016 at 9:33 AM, Ben Watson <bwats...@gmail.com> wrote:
I'm currently running Ansible 2.1.0 and get an error when trying to use the json_query filter.

Example

- name: Display filtered variable contents
  debug: var=item
  with_items: "{{ my_var | json_query('json.[*].percent')}}"

I get the following Ansible error when run on remote hosts

"template error while templating string: no filter named 'json_query'

I know this functionality relies on jmespath, and I do have a task defined to install jmespath via pip, like so (before the debug task above):

- name: Run pip to install jmespath
  raw: pip install jmespath
  become: true
  become_method: sudo

Thanks!

Ben

--
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.
Reply all
Reply to author
Forward
0 new messages