title: Best way to get the IP address of the Ansible control machine
body: <p>I am using Ansible and <code>ufw</code> to setup a firewall on my servers. As part of the <code>ufw</code> rules I would like to allow SSH from the Ansible control machine, but not from anywhere else. My question is - what is the best way to get the IP address of the control machine itself so I can put it into the rule?</p>
  
  <p>I'm aware that I can use <a href="http://docs.ansible.com/ansible/playbooks_variables.html#accessing-complex-variable-data" rel="noreferrer">facts</a> to get the IP address of the machine I am running the playbook on, but I don't see any easy way to get it automatically for the machine that is running ansible.</p>
  
  <p>I'd like to avoid adding a new variable to represent this if possible since it would be nice if it was automatically discoverable, though if that's the only known best way to do it then I will just do that.</p>
  
  <p>EDIT: I found <a href="https://stackoverflow.com/questions/33956453/use-ansible-control-masters-ip-address-in-jinja-template">this duplicate question</a> which is the same as mine, however it also is unanswered so will leave this open for a bit.</p>