Advertisement
theRoUS

Registering multiple task results into a single variable str

Jun 9th, 2016
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.08 KB | None | 0 0
  1. # encoding: UTF-8
  2. # -*- coding: utf-8 -*-
  3. ---
  4. - name: "Experiment with structured task result registrations"
  5.   hosts: 127.0.0.1
  6.  
  7.   tasks:
  8.   - name: "Create the results variable"
  9.     set_fact:
  10.       results: {}
  11.  
  12.   - name: "Generate a first result"
  13.     delegate_to: 127.0.0.1
  14.     command: "echo 'First!'"
  15.     register: task_result
  16.  
  17.   - name: "Load the first result"
  18.     delegate_to: 127.0.0.1
  19.     set_fact:
  20.       results: "{{ results|combine({'first':task_result}) }}"
  21.  
  22.   - name: "Report results after first task"
  23.     delegate_to: 127.0.0.1
  24.     debug:
  25.       var: results
  26.  
  27.   - name: "Generate a second result"
  28.     delegate_to: 127.0.0.1
  29.     command: "echo 'Second!'"
  30.     register: task_result
  31.  
  32.   - name: "Load the second result"
  33.     delegate_to: 127.0.0.1
  34.     set_fact:
  35.       results: "{{ results|combine({'second':task_result}) }}"
  36.  
  37.   - name: "Report results after combining in individual task results manually"
  38.     delegate_to: 127.0.0.1
  39.     debug:
  40.       var: results
  41.  
  42. # Local Variables:
  43. # mode: YAML
  44. # yaml-indent-offset: 2
  45. # indent-tabs-mode: nil
  46. # End:
  47. # vim:sw=2:ts=2:expandtab:textwidth=79:autoindent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement