mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 19:20:22 -07: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:
parent
c157c47802
commit
26bc8ab47a
1 changed files with 29 additions and 28 deletions
|
@ -287,7 +287,7 @@ At a more basic level, they can be used to add chaos and excitement to otherwise
|
||||||
Do-Until Loops
|
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::
|
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.
|
.. 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.
|
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::
|
It's uncommonly used::
|
||||||
|
@ -382,7 +382,7 @@ It's uncommonly used::
|
||||||
|
|
||||||
Using ini file with a loop
|
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::
|
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
|
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.
|
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.
|
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.
|
.. 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
|
.. 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::
|
|
||||||
|
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
|
- name: create servers
|
||||||
digital_ocean: name={{item.name}} state=present ....
|
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.
|
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
|
.. 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.::
|
|
||||||
|
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
|
# main.yml
|
||||||
- name: create servers, pause 3s before creating next
|
- 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>`_
|
`irc.freenode.net <http://irc.freenode.net>`_
|
||||||
#ansible IRC chat channel
|
#ansible IRC chat channel
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue