Skip to content

Commit

Permalink
Additional simpler json_query documentation (ansible#24041)
Browse files Browse the repository at this point in the history
Since json_query treats backticks as delimiters for literals,
some of the examples in the json_query docs can be made a little
simpler. Rather than replacing such examples, demonstrate the
alternative
  • Loading branch information
willthames authored and Prasad Katti committed Oct 1, 2017
1 parent 9b56857 commit 344b6fb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/docsite/rst/playbooks_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ This example shows ports from cluster1::

.. note:: You can use a variable to make the query more readable.

Or, alternatively::

- name: "Display all server names from cluster1"
debug:
var: item
with_items: "{{domain_definition|json_query('domain.server[?cluster=`cluster`].port')}}"

.. note:: Here, quoting literals using backticks avoids escaping quotes and maintains readability.

In this example, we get a hash map with all ports and names of a cluster::

- name: "Display all server ports and names from cluster1"
Expand Down

0 comments on commit 344b6fb

Please sign in to comment.