Ubuntu 如何使用ansible设置FQDN?

Ubuntu 如何使用ansible设置FQDN?,ubuntu,ansible,Ubuntu,Ansible,我觉得推荐的方法不太合适: - name: Set hostname hostname: name=mx.mydomain.net 重新启动后,您可以看到我的fqdn有问题,/etc/hosts中没有任何内容 root@mx:~# 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-

我觉得推荐的方法不太合适:

- name: Set hostname
  hostname: name=mx.mydomain.net
重新启动后,您可以看到我的fqdn有问题,
/etc/hosts
中没有任何内容

root@mx:~# 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

root@mx:~# cat /etc/hostname
mx.mydomain.net

root@mx:~# hostname
mx.mydomain.net

root@mx:~# hostname -f
hostname: Name or service not known

这个Ansible模块的文档似乎不太清楚它到底做了什么。我只是快速查看了一下github上的,根据linux发行版的不同,它似乎只调用/bin/hostname和/或修改/etc/hostname、/etc/sysconfig/network或/etc/conf.d/hostname。这个模块本身实际上并没有以任何方式修改/etc/hosts


如果你认为这是这个模块工作的一个bug,那么我强烈建议你向一个ANDILE开发者提交一个bug报告,你可以这样做。即使您认为应该改进文档,提交一份bug报告,要求修复文档也是很有帮助的。

似乎是saltstack的人做得对,会从这里复制操作谢谢您的建议:)我已经为此编写了我自己的角色,不管怎样似乎工作得很好。主机名模块使用hostname命令更新主机。在那里没有做任何其他事情。