Update lookup.rst (#72831)

##### SUMMARY
Set correct indentation.


##### ISSUE TYPE
- Docs Pull Request

+label: docsite_pr
This commit is contained in:
Simeon Bobylev 2020-12-18 20:55:53 +01:00 committed by GitHub
parent 938199e34a
commit 202689b1c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,13 +36,13 @@ You can use lookup plugins anywhere you can use templating in Ansible: in a play
.. code-block:: YAML+Jinja .. code-block:: YAML+Jinja
vars: 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:: 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: tasks:
- name: count to 3 - name: count to 3
debug: msg={{item}} debug: msg={{ item }}
with_items: [1, 2, 3] 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:: 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::
@ -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 - 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(' ') }}" debug: msg="find the answer here:\n{{ lookup('url', 'https://google.com/search/?q=' + item|urlencode)|join(' ') }}"
with_nested: with_nested:
- "{{lookup('consul_kv', 'bcs/' + lookup('file', '/the/question') + ', host=localhost, port=2000')|shuffle}}" - "{{ 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('sequence', 'end=42 start=2 step=2')|map('log', 4)|list) }}"
- ['a', 'c', 'd', 'c'] - ['a', 'c', 'd', 'c']
.. versionadded:: 2.6 .. versionadded:: 2.6