title: How to get the host name of the current machine as defined in the Ansible hosts file?
body: <p>I'm setting up an Ansible playbook to set up a couple servers. There are a couple of tasks that I only want to run if the current host is my local dev host, named "local" in my hosts file. How can I do this? I can't find it anywhere in the documentation.</p>
  
  <p>I've tried this when statement, but it fails because <code>ansible_hostname</code> resolves to the host name generated when the machine is created, not the one you define in your hosts file.</p>
  
  <pre><code>- name: Install this only for local dev machine
    pip: name=pyramid
    when: ansible_hostname == "local"
  </code></pre>