1.修改/etc/ansible/hosts 以包括servera.lab.example.com作为受管主机。
1.1.将servera.lab.example.com添加到默认清单文件/etc/ansible/hosts的末尾。
sudo vim /etc/ansible/hosts
添加内容:
servera.lab.example.com
1.2.继续编辑/etc/ansible/hosts清单文件,将[webservers]组添加到该文件的末尾,并将serverb.lab.example.com服务器作为组成员
[webservers]
serverb.lab.example.com
2.验证/etc/ansible/hosts清单文件的受管主机。
2.1使用ansible all --list-hosts命令列出默认清单文件中的所有受管主机。
ansible all --list-hosts
2.2使用命令ansible ungrouped --list-hosts,仅列出不属于某个组的受管主机。
ansible ungrouped --list-hosts