From 9c303257043c27f681f3d5fb17d316844266b5a0 Mon Sep 17 00:00:00 2001 From: Sandra McCann Date: Thu, 12 Dec 2019 14:20:08 -0500 Subject: [PATCH] fixed some link nits (#65772) --- docs/docsite/rst/user_guide/playbooks_loops.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/docsite/rst/user_guide/playbooks_loops.rst b/docs/docsite/rst/user_guide/playbooks_loops.rst index 9e6fd59d9f8..b86ebacb076 100644 --- a/docs/docsite/rst/user_guide/playbooks_loops.rst +++ b/docs/docsite/rst/user_guide/playbooks_loops.rst @@ -82,7 +82,7 @@ Either of these examples would be the equivalent of:: state: present groups: "wheel" -You can pass a list directly to a parameter for some plugins. Most of the packaging modules, like :ref:`yum_module` and :ref:`apt_module`, have this capability. When available, passing the list to a parameter is better than looping over the task. For example:: +You can pass a list directly to a parameter for some plugins. Most of the packaging modules, like :ref:`yum ` and :ref:`apt `, have this capability. When available, passing the list to a parameter is better than looping over the task. For example:: - name: optimal yum yum: @@ -111,13 +111,15 @@ If you have a list of hashes, you can reference subkeys in a loop. For example:: - { name: 'testuser1', groups: 'wheel' } - { name: 'testuser2', groups: 'root' } -When combining :ref:`playbooks_conditionals` with a loop, the ``when:`` statement is processed separately for each item. +When combining :ref:`conditionals ` with a loop, the ``when:`` statement is processed separately for each item. See :ref:`the_when_statement` for examples. Iterating over a dictionary --------------------------- -To loop over a dict, use the ``dict2items`` :ref:`dict_filter`:: +To loop over a dict, use the :ref:`dict2items `: + +.. code-block:: yaml - name: create a tag dictionary of non-empty tags set_fact: @@ -268,14 +270,14 @@ There is also a specific lookup plugin ``inventory_hostnames`` that can be used msg: "{{ item }}" loop: "{{ query('inventory_hostnames', 'all:!www') }}" -More information on the patterns can be found on :ref:`intro_patterns` +More information on the patterns can be found in :ref:`intro_patterns`. .. _query_vs_lookup: Ensuring list input for ``loop``: ``query`` vs. ``lookup`` ========================================================== -The ``loop`` keyword requires a list as input, but the ``lookup`` keyword returns a string of comma-separated values by default. Ansible 2.5 introduced a new Jinja2 function named :ref:`query` that always returns a list, offering a simpler interface and more predictable output from lookup plugins when using the ``loop`` keyword. +The ``loop`` keyword requires a list as input, but the ``lookup`` keyword returns a string of comma-separated values by default. Ansible 2.5 introduced a new Jinja2 function named :ref:`query ` that always returns a list, offering a simpler interface and more predictable output from lookup plugins when using the ``loop`` keyword. You can force ``lookup`` to return a list to ``loop`` by using ``wantlist=True``, or you can use ``query`` instead.