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

Add some notes about which features are typically rarely used so folks won't feel like they have to understand them all up front.

This commit is contained in:
Michael DeHaan 2013-10-13 08:57:10 -04:00
parent 44b5b9525f
commit a956c2019f

View file

@ -89,7 +89,7 @@ be used like this::
Looping over Parallel Sets of Data
``````````````````````````````````
.. note:: This is an uncommon thing to want to do, but we're documenting it for completeness. You 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.
Suppose you have the following variable data was loaded in via somewhere::
@ -216,6 +216,8 @@ The registered variable will also have a new key "attempts" which will have the
Finding First Matched Files
```````````````````````````
.. 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.
This isn't exactly a loop, but it's close. What if you want to use a reference to a file based on the first file found
that matches a given criteria, and some of the filenames are determined by variable names? Yes, you can do that as follows::
@ -231,7 +233,7 @@ This tool also has a long form version that allows for configurable search paths
template: src={{ item }} dest=/etc/file.cfg mode=0444 owner=root group=root
with_first_found:
- files:
- ${inventory_hostname}/etc/file.cfg
- "{{inventory_hostname}}/etc/file.cfg"
paths:
- ../../../templates.overwrites
- ../../../templates
@ -245,6 +247,8 @@ This tool also has a long form version that allows for configurable search paths
Iterating Over The Results of a Program Execution
`````````````````````````````````````````````````
.. 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.
Sometimes you might want to execute a program, and based on the output of that program, loop over the results of that line by line.
Ansible provides a neat way to do that, though you should remember, this is always executed on the control machine, not the local
machine::
@ -271,6 +275,8 @@ Should you ever need to execute a command remotely, you would not use the above
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
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.
@ -285,6 +291,8 @@ It's uncommonly used::
Flattening A List
`````````````````
.. 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.
In rare instances you might have several lists of lists, and you just want to iterate over every item in all of those lists. Assume
a really crazy hypothetical datastructure::