From d3a97bfb078c4393142b24d4d2aa3c699bfc94c2 Mon Sep 17 00:00:00 2001 From: Javier Candeira Date: Mon, 15 Jul 2013 14:28:02 +1000 Subject: [PATCH] add documentation for with_nested --- docsite/latest/rst/playbooks2.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docsite/latest/rst/playbooks2.rst b/docsite/latest/rst/playbooks2.rst index 92283d549f..90b6700333 100644 --- a/docsite/latest/rst/playbooks2.rst +++ b/docsite/latest/rst/playbooks2.rst @@ -447,6 +447,25 @@ If you have a list of hashes, you can reference subkeys using things like:: - { name: 'testuser1', groups: 'wheel' } - { name: 'testuser2', groups: 'root' } +Nested Loops +```````````` + +Loops can be nested too: + + - name: give all employees access to every departament's database + mysql_user: name={{ item[0] }} priv={{ item[1] }}.*:* + with_nested: + - [ 'alice', 'bob', 'eve' ] + - [ 'clientdb', 'employeedb', 'providerdb' ] + +As with the case of 'with_items" above, you can use previously defined variables, and you can use their raw name without templating it with '{{ }}'. + + - name: here, 'users' contains the above list of employees + mysql_user: name={{ item[0] }} priv={{ item[1] }}.*:* + with_nested: + - users + - [ 'clientdb', 'employeedb', 'providerdb' ] + Lookup Plugins - Accessing Outside Data ```````````````````````````````````````