title: ansible_default_ipv4.address undefined in docker ubuntu
body: <p>I am trying to run a simple ansible operation which should update a line in /etc/hosts:</p>
  
  <pre><code>- hosts: localhost
    become: true
    vars:
        master_host: "ansible-master"
    tasks:
    - hostname: name="{{master_host}}"
    - name: Add master host to /etc/hosts
      lineinfile: dest=/etc/hosts line="{{ ansible_default_ipv4.address}} {{master_host}}"
                  regexp=".*{{master_host}}\s*$"
  </code></pre>
  
  <p>When I run this in virtualbox with ubuntu 16, it works fine.</p>
  
  <p>When I run it in my ubuntu 16 Docker container, I get:</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field
    'args' has an invalid value, which appears to include a variable that
    is undefined. The error was: 'ansible_default_ipv4' is
    undefined\n\nThe error appears to have been in
    '/home/user/ansible/manage-ansible-master.yml': line 11, column 5, but
    may\nbe elsewhere in the file depending on the exact syntax
    problem.\n\nThe offending line appears to be:\n\n  - hostname:
    name=\"{{master_host}}\"\n  - name: Add master host to /etc/hosts\n<br>
    ^ here\n"}</p>
  </blockquote>
  
  <p>Where is ansible trying to pull the local ip from and why can't it do so in docker?</p>
  
  <p>BTW I have installed net-tools in my docker container and it has an eth0 ip.</p>
  
  <p>On virtualbox and in docker I have a line in /etc/hosts</p>
  
  <blockquote>
    <p>ansible-master 127.0.1.1</p>
  </blockquote>
  
  <p>UPDATE:</p>
  
  <p>I run</p>
  
  <pre><code>ansible all --connection=local -m setup | less
  </code></pre>
  
  <p>on virtualbox ubuntu and Docker ubuntu.</p>
  
  <p>On Virtualbox I get a lot of network-related info that I don't get on Docker:</p>
  
  <pre><code>"ansible_facts": {
          "ansible_all_ipv4_addresses": [
              &lt;ip&gt;, 
              &lt;another ip&gt;
          ], 
          "ansible_all_ipv6_addresses": [
              &lt;ipv6&gt;, 
              &lt;another ipv6&gt;
          ], 
  </code></pre>
  
  <p>Also in virtualbox I get</p>
  
  <pre><code> "ansible_default_ipv4": {
              "address": &lt;value&gt;, 
              "alias": &lt;value&gt;, 
              "broadcast": &lt;value&gt;, 
              "gateway": &lt;value&gt;, 
              "interface": &lt;value&gt;, 
              "macaddress": &lt;value&gt;, 
              "mtu": &lt;value&gt;, 
              "netmask": &lt;value&gt;, 
              "network": &lt;value&gt;, 
              "type": &lt;value&gt;
          }, 
  </code></pre>
  
  <p>None of this appears in Docker.</p>