Merge pull request #17833 from resmo/docs/fix_loops

docsite: various fixes in loops doc
pull/4420/head
scottb 2016-09-30 11:26:46 -07:00 committed by GitHub
commit d88025f0cb
1 changed files with 29 additions and 28 deletions

View File

@ -287,7 +287,7 @@ At a more basic level, they can be used to add chaos and excitement to otherwise
Do-Until Loops
``````````````
.. versionadded: 1.4
.. versionadded:: 1.4
Sometimes you would want to retry a task until a certain condition is met. Here's an example::
@ -369,7 +369,7 @@ Looping Over A List With An Index
.. note:: This is an uncommon thing to want to do, but we're documenting it for completeness. You probably won't be reaching for this one often.
.. versionadded: 1.3
.. versionadded:: 1.3
If you want to loop over an array and also get the numeric index of where you are in the array as you go, you can also do that.
It's uncommonly used::
@ -382,7 +382,7 @@ It's uncommonly used::
Using ini file with a loop
``````````````````````````
.. versionadded: 2.0
.. versionadded:: 2.0
The ini plugin can use regexp to retrieve a set of keys. As a consequence, we can loop over this set. Here is the ini file we'll use::
@ -551,7 +551,7 @@ More information on the patterns can be found on :doc:`intro_patterns`
Loop Control
````````````
.. versionadded: 2.1
.. versionadded:: 2.1
In 2.0 you are again 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.
Ansible by default sets the loop variable `item` for each loop, which causes these nested loops to overwrite the value of `item` from the "outer" loops.
@ -575,8 +575,9 @@ As of Ansible 2.1, the `loop_control` option can be used to specify the name of
.. note:: If Ansible detects that the current loop is using a variable which has already been defined, it will raise an error to fail the task.
.. versionadded: 2.2
When using complex data structures for looping the display might get a bit too "busy", this is where the c(label) directive comes to help::
.. versionadded:: 2.2
When using complex data structures for looping the display might get a bit too "busy", this is where the C(label) directive comes to help::
- name: create servers
digital_ocean: name={{item.name}} state=present ....
@ -593,8 +594,9 @@ When using complex data structures for looping the display might get a bit too "
This will now display just the 'label' field instead of the whole structure per 'item', it defaults to '"{{item}}"' to display things as usual.
.. versionadded: 2.2
Another option to loop control is c(pause), which allows you to control the time (in seconds) between execution of items in a task loop.::
.. versionadded:: 2.2
Another option to loop control is C(pause), which allows you to control the time (in seconds) between execution of items in a task loop.::
# main.yml
- name: create servers, pause 3s before creating next
@ -658,4 +660,3 @@ information. Each of the above features are implemented as plugins in ansible,
`irc.freenode.net <http://irc.freenode.net>`_
#ansible IRC chat channel