local hosts entry override ansible_domain and ansible_fqdn

652 views
Skip to first unread message

Julien Tognazzi

unread,
Dec 15, 2015, 7:02:56 AM12/15/15
to Ansible Project
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,

$ 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.

Julien Tognazzi

unread,
Dec 15, 2015, 10:07:26 AM12/15/15
to Ansible Project
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.

Brian Coca

unread,
Dec 15, 2015, 10:12:27 AM12/15/15
to Ansible Project
this is how the underlying python functions and system calls work.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/935f1072-9143-497f-b640-8c86f90bbebb%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Fff Fff

unread,
Dec 15, 2015, 10:54:06 AM12/15/15
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages