hostname模块用于修改主机名(注意: 它不能修改/etc/hosts文件)
https://docs.ansible.com/ansible/latest/modules/hostname_module.html#hostname-module
将192.168.98.203机器的主机名修改为zutuanxue_node3
[root@manage01 ~]# ansible -m hostname -a "name=zutuanxue_node3" 192.168.98.203
192.168.98.203 | CHANGED => {
"ansible_facts": {
"ansible_domain": "",
"ansible_fqdn": "zutuanxue_node3",
"ansible_hostname": "zutuanxue_node3",
"ansible_nodename": "zutuanxue_node3",
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"name": "zutuanxue_node3"
}
备注:批量修改需要使用playbook剧本
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有