2014-09-22 38 views
7

似乎推薦的方法不能很好地對我工作:如何設置FQDN與ansible?

- name: Set hostname 
    hostname: name=mx.mydomain.net 

重啓後,你可以看到我有問題FQDN,沒有在/etc/hosts

[email protected]:~# cat /etc/hosts 
127.0.0.1 localhost 
127.0.1.1 mail mail 

# The following lines are desirable for IPv6 capable hosts 
::1  ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 

[email protected]:~# cat /etc/hostname 
mx.mydomain.net 

[email protected]:~# hostname 
mx.mydomain.net 

[email protected]:~# hostname -f 
hostname: Name or service not known 
+0

似乎是鹽堆傢伙它是否正確https://github.com/saltstack-formulas/hostsfile-formula/blob/master/hostsfile/hostname.sls將從這裏複製行動 – holms 2014-09-22 18:18:40

回答

7

看來這個Ansible模塊的文檔只是不完全清楚它的功能。我只是簡單地看了看github上的source code for the hostname module,看起來,根據linux發行版,它只調用/ bin/hostname和/或修改/ etc/hostname,/ etc/sysconfig/network或/etc/conf.d /主機名。這個模塊本身並沒有以任何方式實際修改/ etc/hosts。

如果您認爲這是該模塊工作方式中的錯誤,那麼我強烈建議您向Ansible開發人員提交錯誤報告,您可以使用here。即使你認爲文檔應該被改進,那麼提交一個錯誤報告會要求修復文檔會很有幫助。

+1

感謝您的意見:)我已經爲此寫了我自己的角色,無論如何,似乎運作良好。 https://github.com/holms/ansible-fqdn主機名模塊使用hostname命令更新主機。那裏沒有別的事情正在做。 – holms 2014-09-29 08:04:03