# Setup facts: ansible\_default\_ipv4 is empty, even when interface is active with an ip address

**URL:** <https://forum.ansible.com/t/setup-facts-ansible-default-ipv4-is-empty-even-when-interface-is-active-with-an-ip-address/19795>\
**Category:** Ansible Project\
**Created:** [November 18, 2015, 4:27pm UTC](https://forum.ansible.com/t/setup-facts-ansible-default-ipv4-is-empty-even-when-interface-is-active-with-an-ip-address/19795 "2015-11-18T16:27:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 18, 2015, 4:27pm UTC](https://forum.ansible.com/t/setup-facts-ansible-default-ipv4-is-empty-even-when-interface-is-active-with-an-ip-address/19795/1 "2015-11-18T16:27:46Z")

</div>

I am writing a playbook where I want to name a file including the ipaddress. However, my default ipv4 in the facts is empty, even though my interface is active and has a static ip. My target machine is CentOS 7.1, and my ansible version is 1.9.3.

**“ansible\_default\_ipv4”: {},**  
“ansible\_default\_ipv6”: {  
“address”: “REDACTED”,  
“gateway”: “REDACTED”,  
“interface”: “enp5s0”,  
–break–  
“ansible\_enp5s0”: {  
“active”: true,  
“device”: “enp5s0”,  
“ipv4”: {  
**“address”: “REDACTED”,**  
“netmask”: “255.255.255.0”,  
“network”: “REDACTED”

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 18, 2015, 6:05pm UTC](https://forum.ansible.com/t/setup-facts-ansible-default-ipv4-is-empty-even-when-interface-is-active-with-an-ip-address/19795/2 "2015-11-18T18:05:44Z")

</div>

This might just be a configuration issue with my host. I’m still working on bootstrapping it to be my new control host. I also just realized that AWS EC2 hosts give their internal addresses, not public, so default ipv4 won’t always do what I need.

My goal is to fetch a set of ssh public\_key files gathered from remote hosts, and name them with user + the hosts’ public ip addresses. Is there a way to extract the ips from a group of hosts? I am ending up with one file rather than a file for each host when I use the following:

My task:

- name: copy new keys back to repo  
fetch: “src=/home/ansible/.ssh/id\_rsa.pub  
dest=/home/ansible/public\_keys/ansible\_{{item}}  
flat=yes”  
with\_items:
- ‘{{ hosts }}’

On the command line I specify --extra-vars “hosts=ipaservers” and end up with one file named ansible\_ipaservers with only one key in it. I’m hoping to end up with something like ansible\_52.x.x.x, ansible\_192.x.x.x, ansible\_176.x.x.x files instead, each with the ansible user’s key on that host.
