title: Ansible get hostnames from one group as a variable to another play
body: <p>Here is inventory file. </p>
  
  <pre><code>[abc]
  host1
  host2
  
  [123]
  host3
  </code></pre>
  
  <p>And main.yml </p>
  
  <pre><code>#play1
  - hosts: abc
    roles:
      - { role: abc }
    tasks: 
      ...
  #play2
  - hosts: 123
    roles:
      - { role: 123 }
    tasks:
      debug: msg="{{inventory_hostname}}"
  </code></pre>
  
  <p>Basically I need to run some commands in host3 and the commands need host1 and host2 in it. So how can I get host1 and host2 which are in group abc into play2 <code>debug: msg="{{inventory_hostname}}"</code>, I know  inventory_hostname is getting host3. is there any other way I can get only host1 and host2. Let me know if I'm not clear. </p>
  
  <p>Thanks in Advance., </p>