fixed some link nits (#65772)
This commit is contained in:
parent
860cacc54f
commit
9c30325704
1 changed files with 7 additions and 5 deletions
|
@ -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 <yum_module>` and :ref:`apt <apt_module>`, 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 <playbooks_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 <dict_filter>`:
|
||||
|
||||
.. 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 <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.
|
||||
|
||||
|
|
Loading…
Reference in a new issue