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

added docs for include with_items and usage of multiple lopo vars (item) #12886

Merged
merged 1 commit into from
Oct 26, 2015
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
30 changes: 30 additions & 0 deletions docsite/rst/playbooks_loops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,36 @@ Subsequent loops over the registered variable to inspect the results may look li
when: item.rc != 0
with_items: "{{echo.results}}"



.. _loops_and_includes

Loops and Includes

``````````````````

In 2.0 you are able to use with_ loops and task includes (but not playbook includes), this adds the ability to loop over the set of tasks in one shot.
There are a couple of things that you need to keep in mind, a included task that has it's own with_ loop will overwrite the value of the special `item` variable.
So if you want access to both the include's `item` and the current task's `item` you should use `set_fact` to create a alias to the outer one.::


- include: test.yml
with_items:
- 1
- 2
- 3

in test.yml::

- set_fact: outer_loop="{{item}}"

- debug: msg="outer item={{outer_loop}} inner item={{item}}"
with_items:
- a
- b
- c


.. _writing_your_own_iterators:

Writing Your Own Iterators
Expand Down