mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-25 05:23:58 -07:00 
			
		
		
		
	Update loop docs to also describe register:'s value when inside loop. (#20991)
This commit is contained in:
		
					parent
					
						
							
								fee6e2953b
							
						
					
				
			
			
				commit
				
					
						1df14ed121
					
				
			
		
					 1 changed files with 10 additions and 1 deletions
				
			
		|  | @ -463,7 +463,7 @@ That's how! | ||||||
| Using register with a loop | Using register with a loop | ||||||
| `````````````````````````` | `````````````````````````` | ||||||
| 
 | 
 | ||||||
| When using ``register`` with a loop, the data structure placed in the variable will contain a ``results`` attribute that is a list of all responses from the module. | After using ``register`` with a loop, the data structure placed in the variable will contain a ``results`` attribute that is a list of all responses from the module. | ||||||
| 
 | 
 | ||||||
| Here is an example of using ``register`` with ``with_items``:: | Here is an example of using ``register`` with ``with_items``:: | ||||||
| 
 | 
 | ||||||
|  | @ -520,6 +520,15 @@ Subsequent loops over the registered variable to inspect the results may look li | ||||||
|       when: item.rc != 0 |       when: item.rc != 0 | ||||||
|       with_items: "{{ echo.results }}" |       with_items: "{{ echo.results }}" | ||||||
| 
 | 
 | ||||||
|  | During iteration, the result of the current item will be placed in the variable: | ||||||
|  | 
 | ||||||
|  |     - shell: echo "{{ item }}" | ||||||
|  |       with_items: | ||||||
|  |         - one | ||||||
|  |         - two | ||||||
|  |       register: echo | ||||||
|  |       changed_when: echo.stdout != "one" | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _looping_over_the_inventory: | .. _looping_over_the_inventory: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue