title: get a particular host name's ip with ansible
body: <p>I have a host file that looks roughly like this:</p>
  
  <pre><code>[kibanamaster]
  efk host_ip host user passwd
  [elasticnode]
  esnode host_ip user passwd
  </code></pre>
  
  <p>and I am trying something in the style of </p>
  
  <pre><code>- name: get ip address node1
    debug: var=hostvars[inventory_host]['esnode']['ansible_default_ipv4']['address'] 
    register: es_node1
  </code></pre>
  
  <p>But I get variable not defined. Anyone outthere able to help?</p>
  
  <p>EDIT: 
  If I do </p>
  
  <pre><code>debug: var=hostvars[LOG1]['esnode']['ansible_default_ipv4']['address']
  register: node_1 
  </code></pre>
  
  <p>I get </p>
  
  <p><code>{"hostvars[LOG1]['ansible_default_ipv4']['address']": "VARIABLE IS NOT DEFINED!"}</code></p>