1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docsite: various fixes in loops doc

- "new in version ..." did not always show up
- indentation in examples
- minor style cleanup (whitespace)
This commit is contained in:
Rene Moser 2016-09-30 16:01:56 +02:00
parent c157c47802
commit 26bc8ab47a

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,12 +575,13 @@ 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 ....
with_items:
with_items:
- name: server1
disks: 3gb
ram: 15Gb
@ -593,16 +594,17 @@ 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
digital_ocean: name={{item}} state=present ....
with_items:
with_items:
- server1
- server2
loop_control:
loop_control:
pause: 3
@ -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