ansible / ansible-builder

An Ansible execution environment builder
Other
289 stars 93 forks source link

"Selecting JSON data: JSON queries" — misspelling in the example and the confusing JSON #618

Closed nnlkcncff closed 11 months ago

nnlkcncff commented 11 months ago

To get a hash map with all ports and names of a cluster:

- name: Display all server ports and names from cluster1
  ansible.builtin.debug:
    var: item
  loop: "{{ domain_definition | community.general.json_query(server_name_cluster1_query) }}"
  vars:
    server_name_cluster1_query: "domain.server[?cluster=='cluster2'].{name: name, port: port}"


The example in Selecting JSON data: JSON queries section contains a mistake in server_name_cluster1_query, the value should be "domain.server[?cluster=='cluster1'].{name: name, port: port}". The same problem on the page community.general.json_query filter – Select a single element or a data subset from a complex data structure.

Also the JSON example at the beginning of the section must be { "domain": {...} }, but it is { "domain_definition": "domain": {...} }, so all the examples will not work. Obviously this is done to create an association of the variable name with the JSON section, but it would be better to use the correct form.

nnlkcncff commented 11 months ago

Sorry, this is mistake — the issue was opened on the wrong repo.