title: ansible: Extract value from the register variables to use it in other plays within same playbook
body: <p>I'm setting up complete environment using ansible. For some reason, ansible is not picking up variable values.</p>
  
  <p>I'm using ansible 2.1.1.0</p>
  
  <p>Here's a strip example of what I'm trying to do:
  I have registered my vpc with <code>register: ec2_vpc</code>. </p>
  
  <pre><code>1. #This didn't works
      - name: Add to host vars
        add_host:
              name: vpc_vars
              groups: vpc_subnets
              vpc_subnet_id: "{{ ec2_vpc.subnets[0].id }}"
              vpcid: "{{ ec2_vpc.vpc_id }}"
      - debug: var=vpc_subnet_id
      - debug: var=vpcid
  
  2. These works
      - name: Record vpc id
        debug: var=ec2_vpc.vpc_id
  
      - name: Record subnet id
        debug: var=ec2_vpc.subnets[0].id
  </code></pre>
  
  <p>Resulted json of my above strip:</p>
  
  <pre><code>TASK [debug] *******************************************************************
  ok: [localhost] =&gt; {
      "vpc_subnet_id": "VARIABLE IS NOT DEFINED!"
  }
  
  TASK [debug] *******************************************************************
  ok: [localhost] =&gt; {
      "vpcid": "VARIABLE IS NOT DEFINED!"
  }
  
  TASK [Record vpc id] ***********************************************************
  ok: [localhost] =&gt; {
      "ec2_vpc.vpc_id": "vpc-4sdh3832f"
  }
  
  TASK [Record subnet id] ********************************************************
  ok: [localhost] =&gt; {
      "ec2_vpc.subnets[0].id": "subnet-edfjdh3482"
  }
  </code></pre>
  
  <p>Why is my first syntax not picking the value instead its giving <code>VARIABLE IS NOT DEFINED!</code></p>
  
  <p><strong>Updated:</strong> Here my 2nd syntax describes I am correctly sorting out the value from the JSON result of registered variable. But I want it work for my 1st syntax which means I want to add hosts variables to dynamic inventory. So that I can reuse it in another play</p>