D
D
Daniil Muidinov2019-08-07 19:30:00
Ansible
Daniil Muidinov, 2019-08-07 19:30:00

How to make json_query queries correctly?

It is required using ansible to parse JSON of the following format
www.mocky.io/v2/5d4af1033300005b000f6100 Make
a request similar to
curl -s http://www.mocky.io/v2/5d4af1033300005b000f6100|jq '.[]."scopedTarget.Config.A (something in [A.cfg.yml])".fontTemplates[]|{"name"}'
How to correctly compose a request in json_query format
What are the online services where you can quickly check the request in jmespath format and immediately substitute it into the playbook?
This query returns an empty value

---
- hosts: localhost
  connection: local
  gather_facts: False
  tasks:

  - name: "Get JSON"
    uri:
      url: http://www.mocky.io/v2/5d4af1033300005b000f6100
      body_format: json
    register: json_response

  - debug:
      msg: "{{ json_response.json | json_query( '\"scopedTarget.Config.A (something in [A.cfg.yml])\"' ) }}"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question