summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2015-10-26 13:27:09 -0400
committerBrian Coca <bcoca@ansible.com>2015-10-26 13:27:09 -0400
commit0fd1d1691bcaf4e2fbafcb725f19d3af0c62bec6 (patch)
tree6c112b8cfb3e698007b7cb1a7c50604ddbdc62c6
parent5b33b0ddfd2bd8da45f196a550308aa4b18a2050 (diff)
parent6637982debc12cdb7b378976207b1dac9a74a636 (diff)
downloadansible-0fd1d1691bcaf4e2fbafcb725f19d3af0c62bec6.tar.gz
Merge pull request #12886 from bcoca/doc_with_include
added docs for include with_items and usage of multiple lopo vars (item)
-rw-r--r--docsite/rst/playbooks_loops.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/docsite/rst/playbooks_loops.rst b/docsite/rst/playbooks_loops.rst
index a876fd0c72..fef48ca49a 100644
--- a/docsite/rst/playbooks_loops.rst
+++ b/docsite/rst/playbooks_loops.rst
@@ -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