title: How to get IP address of host when passed as extra-vars in Ansible?
body: <p>Say I am passing the hostnames to an Ansible playbook like so:</p>
  
  <pre><code>ansible-playbook ansible/db-playbook.yml --extra-vars "master=mydb-master, slave=mydb-slave"
  </code></pre>
  
  <p>In the playbook I want to access the actual ip address of the <code>mydb-slave</code> host:</p>
  
  <pre><code>- name: Copy ssh key to Slave
    command: ... "{{ mydb-slave }}"
  </code></pre>
  
  <p>In this case the output is the string literal <code>mydb-slave</code>, but I require the full <code>ip</code> address.</p>