# empty ansible\_domain from setup

**URL:** <https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944>\
**Category:** Ansible Project\
**Created:** [December 4, 2015, 11:59pm UTC](https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944 "2015-12-04T23:59:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![markham\_breitbach](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@markham\_breitbach](https://forum.ansible.com/u/markham_breitbach)\
**Post date:** [December 4, 2015, 11:59pm UTC](https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944/1 "2015-12-04T23:59:40Z")

</div>

I am running ansible 1.9.3 under FreeBSD 10.2 to manage other FreeBSD hosts.

I am trying to figure out why one host comes back with ansible\_domain undefined, when it is fine for another host.

AFAIK both hosts are configured identically.

Can someone tell me how the value for this is determined?

Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 5, 2015, 1:17am UTC](https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944/2 "2015-12-05T01:17:36Z")

</div>

this is the python code that figures out the domain:  
`  
&nbsp;&nbsp;self.facts['fqdn'] = socket.getfqdn()  
...  
&nbsp;&nbsp;self.facts['domain'] = '.'.join(self.facts['fqdn'].split('.')[1:])  
`  
^ basically splits from fqdn after the first . , so "www.example.com"  
would return "example.com"

socket is a core python library and the method is explained here (with  
some jumps) [https://docs.python.org/2/library/socket.html#socket.getfqdn](https://docs.python.org/2/library/socket.html#socket.getfqdn)

Hope this helps narrow it down.

---

<div class="post-metadata">

**Author:** ![markham\_breitbach](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@markham\_breitbach](https://forum.ansible.com/u/markham_breitbach)\
**Post date:** [December 7, 2015, 4:24pm UTC](https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944/3 "2015-12-07T16:24:38Z")

</div>

Thanks Brian, that’s a great place to start. I will see where that take me.

-Markham

---

<div class="post-metadata">

**Author:** ![markham\_breitbach](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@markham\_breitbach](https://forum.ansible.com/u/markham_breitbach)\
**Post date:** [December 8, 2015, 10:44pm UTC](https://forum.ansible.com/t/empty-ansible-domain-from-setup/19944/4 "2015-12-08T22:44:34Z")

</div>

SOLVED!

Also found this post helpful: [https://groups.google.com/forum/#!msg/ansible-project/z27N4scKS-I/UfWyVk8Mug8J](https://groups.google.com/forum/#!msg/ansible-project/z27N4scKS-I/UfWyVk8Mug8J)

It was an ordering issue within the /etc/hosts file.  
I have some local aliasing setup as an artifact of legacy systems, and socket.getfqdn resolves these in order, where ansible grabs the first element for ansible\_fqdn and ansible\_domain.

`192.0.2.2 localnickname 192.0.2.2 hostname.example.com hostname`

These needed to be reversed to get the expected results
