# local hosts entry override ansible\_domain and ansible\_fqdn

**URL:** <https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019>\
**Category:** Ansible Project\
**Created:** [December 15, 2015, 12:02pm UTC](https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019 "2015-12-15T12:02:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Tognazzi](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Julien\_Tognazzi](https://forum.ansible.com/u/Julien_Tognazzi)\
**Post date:** [December 15, 2015, 12:02pm UTC](https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019/1 "2015-12-15T12:02:56Z")

</div>

Hi all,

Is it the expected behavior that the value of ansible\_domain and ansible\_fqdn changes if an entry in /etc/hosts match the server ip ?

With no entry in /etc/hosts

$ ansible -i test localhost -m setup | grep “domain|fqdn”

“ansible\_domain”: “mydomain.ch”,  
“ansible\_fqdn”: “myserver.mydomain.ch”,  
“facter\_domain”: “mydomain.ch”,  
“facter\_fqdn”: “myserver.mydomain.ch”,

Then if I add the following entry in /etc/hosts corresponding with the IP of the server,  
1.2.3.4 otherserver.otherdomain.ch

$ ansible -i test localhost -m setup | grep “domain|fqdn”  
“ansible\_domain”: “otherdomain.ch”,  
“ansible\_fqdn”: “otherserver.otherdomain.ch”,

“facter\_domain”: “mydomain.ch”,  
“facter\_fqdn”: “myserver.mydomain.ch”,

$ ansible --version

ansible 1.9.2

Regards,

Julien.

---

<div class="post-metadata">

**Author:** ![Julien\_Tognazzi](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Julien\_Tognazzi](https://forum.ansible.com/u/Julien_Tognazzi)\
**Post date:** [December 15, 2015, 3:07pm UTC](https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019/2 "2015-12-15T15:07:26Z")

</div>

I justed tested with ansible 2 RC2 and I have the same behavior.

Maybe I should add that the server is a CentOS 6 box.

---

<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 15, 2015, 3:12pm UTC](https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019/3 "2015-12-15T15:12:18Z")

</div>

this is how the underlying python functions and system calls work.

---

<div class="post-metadata">

**Author:** ![Fff\_Fff](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Fff\_Fff](https://forum.ansible.com/u/Fff_Fff)\
**Post date:** [December 15, 2015, 3:54pm UTC](https://forum.ansible.com/t/local-hosts-entry-override-ansible-domain-and-ansible-fqdn/20019/4 "2015-12-15T15:54:06Z")

</div>

Are you sure you have fqdn set up properly? It’s not just /etc/hosts that needs to be setup for properly configued fqdn. It is a bit different between different Linux flavors and even version of flavors as well. For example, Ubuntu/Debian and CentOS 7 also make use of /etc/ hostname whereas I believe CentOS 6 uses /etc/sysconfig/network. Sometimes you can get away with just /etc/hosts but there are times where that is not good enough.
