文章目录
1.配置主机清单
下表列出了有关四个受管主机的信息。您将根据主机的用途、所在的城市以及它所属的部署环境,将每个主机分配给多个组以进行管理。此外,美国城市组(罗利和山景城)必须设为组****us****的子项(children),这样美国的主机就可以作为一 个组进行管理。
| 主机名称 | 用途 | 位置 | 运行环境 |
| ---------------------- - | --------- | ------------------ | --------------- |
| servera.lab.example.com | Web服务器 | 罗利raleigh | 开发development |
| serverb.lab.example.com | Web服务器 | 罗利 | 测试testing |
| serverc.lab.example.com | Web服务器 | 山景城mountainview | 生产production |
| serverd.lab.example.com | Web服务器 | 伦敦london | 生产 |
[root@server ~]# cd /home
[root@server home]# vim /ansible.cfg
[defaults]
inventory=/home/inventory
[root@server home]# vim inventory
[raleigh]
servera.lab.example.com
serverb.lab.example.com
[mountainview]
serverc.lab.example.com
[london]
serverd.lab.example.com
[development]
servera.lab.example.com
[testing]
serverb.lab.example.com
[production]