title: Using register variable to store values for multi host play
body: <p>I have an ansible playbook which contains two plays, the output of first play is to be  used by the second. So I'm using register variable to store the output. The problem is my play is intended to work on multi hosts rather than single host and the output of register is overridden each time and I don't have the values for last (n-1) executions.</p>
  
  <p>My playbook looks like this:</p>
  
  <pre><code>- name: Perform task 
    hosts:  db_server
    connection: local
    gather_facts: no
    vars:
      - method: "{{ method }}"
  
    roles:
      - {role: run_custom_module, tags: ["maintenance"]}
  
  
  - name: Second task based on output of first
    hosts:  db_server
    connection: local
    gather_facts: no
    vars:
      - method: "{{ method }}"
  
    roles:
      - {role: run_custom_module, when: result=="some_string"}
  </code></pre>
  
  <p>The role run_custom_module looks like this:</p>
  
  <pre><code>- name: Executing the custom module
    run_custom_module:
        task: "Run custom py module"
        var: "{{ method }}"
    register: result
  </code></pre>
  
  <p>The inventory file looks like:</p>
  
  <pre><code>[db_server]
  1.1.1.1
  2.2.2.2
  3.3.3.3
  </code></pre>
  
  <p>In case of with_items, the register variable store the output in a list called <strong>results</strong>, refer <a href="http://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop" rel="noreferrer">here</a>. On similar grounds, how can I store the output of multi host play in the register variable so that it can be used in second play of the same playbook?</p>