Browse code

Merge pull request #5357 from sivel/no-or-higher

Do not place (or higher) in min_ansible_version

Michael DeHaan authored on 2013/12/20 04:02:17
Showing 2 changed files
... ...
@@ -509,7 +509,7 @@ def execute_init(args, options):
509 509
                 author = 'your name',
510 510
                 company = 'your company (optional)',
511 511
                 license = 'license (GPLv2, CC-BY, etc)',
512
-                min_ansible_version = '1.2 (or higher)',
512
+                min_ansible_version = '1.2',
513 513
                 platforms = platform_groups,
514 514
                 categories = categories,
515 515
             )
... ...
@@ -318,6 +318,66 @@ That's how!
318 318
 
319 319
 .. _writing_your_own_iterators:
320 320
 
321
+Using register with a loop
322
+``````````````````````````
323
+
324
+When using ``register`` with a loop the data strucutre placed in the variable during a loop, will contain a ``results`` attribute, that is a list of all responses from the module.
325
+
326
+Here is an example of using ``register`` with ``with_items``
327
+
328
+    - shell: echo "{{ item }}"
329
+      with_items:
330
+        - one
331
+        - two
332
+      register: echo
333
+
334
+This differs from the data strucutre returned when using ``register`` without a loop::
335
+
336
+    {
337
+        "changed": true,
338
+        "msg": "All items completed",
339
+        "results": [
340
+            {
341
+                "changed": true,
342
+                "cmd": "echo \"one\" ",
343
+                "delta": "0:00:00.003110",
344
+                "end": "2013-12-19 12:00:05.187153",
345
+                "invocation": {
346
+                    "module_args": "echo \"one\"",
347
+                    "module_name": "shell"
348
+                },
349
+                "item": "one",
350
+                "rc": 0,
351
+                "start": "2013-12-19 12:00:05.184043",
352
+                "stderr": "",
353
+                "stdout": "one"
354
+            },
355
+            {
356
+                "changed": true,
357
+                "cmd": "echo \"two\" ",
358
+                "delta": "0:00:00.002920",
359
+                "end": "2013-12-19 12:00:05.245502",
360
+                "invocation": {
361
+                    "module_args": "echo \"two\"",
362
+                    "module_name": "shell"
363
+                },
364
+                "item": "two",
365
+                "rc": 0,
366
+                "start": "2013-12-19 12:00:05.242582",
367
+                "stderr": "",
368
+                "stdout": "two"
369
+            }
370
+        ]
371
+    }
372
+
373
+Subsequent loops over the registered variable to inspect the results may look like::
374
+
375
+    - name: Fail if return code is not 0
376
+      fail:
377
+        msg: "The command ({{ item.cmd }}) did not have a 0 return code"
378
+      when: item.rc != 0
379
+      with_items: echo.results
380
+
321 381
 Writing Your Own Iterators
322 382
 ``````````````````````````
323 383