title: How create combined variable in Ansible from multiple hosts
body: <p>Scenario example:</p>
  <p><em>inventory.ini file:</em></p>
  <pre><code>[web-servers]
  web1.local ansible_host=10.10.10.11
  web2.local ansible_host=10.10.10.12
  web3.local ansible_host=10.10.10.13
  
  ...
  </code></pre>
  <p>also, let's say I have a <em>playbook.yml</em> ready to be executed</p>
  <pre><code>- hosts: web-servers
    become: true
    role: 
      - xxx
      - yyy
  </code></pre>
  <p>Wanted result is JSON VARIABLE <code> var_a = [{'hostname':'web1.local', 'ip_address':'10.10.10.11' }, {'hostname':'web2.local', 'ip_address':'10.10.10.12' },{'hostname':'web3.local', 'ip_address':'10.10.10.13'}]</code>
  This variable should be visible in roles</p>
  <p><strong>Question: Is this even possible and if yes how to achieve it?</strong></p>
  <p>The purpose of this is to append <code>/etc/hosts</code> in all web-servers (information about all web servers in a group). When the playbook is executed Variable will be used to fill host entries and for other purposes.</p>
  <p>Maybe ansible has other methods to achieve this</p>