title: Ansible: How do I get IP address from only FQDN in Ansible?
body: <p>So, here's the setup. <br> </p>
  
  <p>I am passing a list of FQDN's via extra vars to the playbook, but the key of control machine are copied with their corresponding IP addresses. Also their is no specific group of these in the inventory. <br> </p>
  
  <p>The host for this playbook is a server which may or may not be part of this list that I am passing via extra vars. So, the playbook doesn't have facts of these nodes whatsoever. <br> </p>
  
  <p>So, my question is how do I get the IP addresses of the respective hosts on the fly so that I can loop over them to do some checks for some properties that I have set using their FQDN's via another playbook/ role previously. (Note: I strictly need FQDN's to set these said properties) <br> </p>
  
  <p>I have used delegate_to module, and passing FQDN's and it works but it asks if I want to continue connecting(yes/ no) and waits for user input for the initial run (if given yes, It works as expected). Is their any other simpler, cleaner way to solve this? <br>  (Note: Bare in mind I cannot modify the contents of inventory like putting alias etc) <br> </p>
  
  <h2>Here is the snippet of the code: <br> </h2>
  
  <pre><code>- name: Checks
    become_user: hdfs
    shell: hdfs dfsadmin –report
    delegate_to: "{{ item.host_name }}"
    with_items:
      - "{{rackDetails}}"
  </code></pre>
  
  <h2>Here is the snippet of the master yml file where the above role is called : <br> </h2>
  
  <pre><code>- name: Checks for the property
    hosts: servernode
    roles:
      - Checks
  </code></pre>
  
  <h2>Inventory code snippet looks like this: <br> </h2>
  
  <blockquote>
    <p>[servernode] <br> 
    10.0.2.15 ansible_ssh_user=grant ansible_ssh_pass=grant <br> 
    [all] <br> 
    10.0.2.15 ansible_ssh_user=grant ansible_ssh_pass=grant  <br> 
    10.0.2.16 ansible_ssh_user=grant ansible_ssh_pass=grant <br> 
    10.0.2.17 ansible_ssh_user=grant ansible_ssh_pass=grant <br> 
    10.0.2.18 ansible_ssh_user=grant ansible_ssh_pass=grant <br> 
    10.0.2.19 ansible_ssh_user=grant ansible_ssh_pass=grant <br> </p>
  </blockquote>
  
  <h2>And finally, this is what I am passing via extra vars:</h2>
  
  <pre><code>{"rackDetails":[{"host_name":"prod_node1.paas.com","rack_name":"/rack1"},{"host_name":"prod_node2.paas.com","rack_name":"/rack2"},{"host_name":"prod_node3.paas.com","rack_name":"/rack3"}]}
  </code></pre>