Ansible Inventory: Difference between revisions
Created page with "批量管理主机的时候, 需要预先定义主机或者组, 这个文件叫 Inventory, 默认位于 /etc/ansible/hosts. /etc/ansible/hosts 文件的格式如下:<syntaxhi..." |
No edit summary |
||
Line 1: | Line 1: | ||
批量管理主机的时候, 需要预先定义主机或者组, 这个文件叫 Inventory, 默认位于 /etc/ansible/hosts. | 批量管理主机的时候, 需要预先定义主机或者组, 这个文件叫 Inventory, 默认位于 /etc/ansible/hosts. | ||
/etc/ansible/hosts 文件的格式如下:<syntaxhighlight lang="bash"> | /etc/ansible/hosts 文件的格式如下: | ||
<syntaxhighlight lang="bash"> | |||
mail.example.com | mail.example.com | ||
Line 14: | Line 16: | ||
db | db | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* 指定主机 mail.example.com | |||
* 指定主机组 web, db | |||
* 主机组嵌套 prod | |||
<br /> |
Revision as of 02:01, 13 April 2020
批量管理主机的时候, 需要预先定义主机或者组, 这个文件叫 Inventory, 默认位于 /etc/ansible/hosts.
/etc/ansible/hosts 文件的格式如下:
mail.example.com
[web]
web[1:5].example.com
[db]
db[1:3].example.com
[prod:children]
web
db
- 指定主机 mail.example.com
- 指定主机组 web, db
- 主机组嵌套 prod