Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lookup.rst #72831

Merged
merged 1 commit into from Dec 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/docsite/rst/plugins/lookup.rst
Expand Up @@ -36,13 +36,13 @@ You can use lookup plugins anywhere you can use templating in Ansible: in a play
.. code-block:: YAML+Jinja

vars:
file_contents: "{{lookup('file', 'path/to/file.txt')}}"
file_contents: "{{ lookup('file', 'path/to/file.txt') }}"

Lookups are an integral part of loops. Wherever you see ``with_``, the part after the underscore is the name of a lookup. For this reason, most lookups output lists and take lists as input; for example, ``with_items`` uses the :ref:`items <items_lookup>` lookup::

tasks:
- name: count to 3
debug: msg={{item}}
debug: msg={{ item }}
with_items: [1, 2, 3]

You can combine lookups with :ref:`filters <playbooks_filters>`, :ref:`tests <playbooks_tests>` and even each other to do some complex data generation and manipulation. For example::
Expand All @@ -51,8 +51,8 @@ You can combine lookups with :ref:`filters <playbooks_filters>`, :ref:`tests <pl
- name: valid but useless and over complicated chained lookups and filters
debug: msg="find the answer here:\n{{ lookup('url', 'https://google.com/search/?q=' + item|urlencode)|join(' ') }}"
with_nested:
- "{{lookup('consul_kv', 'bcs/' + lookup('file', '/the/question') + ', host=localhost, port=2000')|shuffle}}"
- "{{lookup('sequence', 'end=42 start=2 step=2')|map('log', 4)|list)}}"
- "{{ lookup('consul_kv', 'bcs/' + lookup('file', '/the/question') + ', host=localhost, port=2000')|shuffle }}"
- "{{ lookup('sequence', 'end=42 start=2 step=2')|map('log', 4)|list) }}"
- ['a', 'c', 'd', 'c']

.. versionadded:: 2.6
Expand Down