doc: update ansible.md (#31)

This commit is contained in:
jaywcjlove 2022-11-09 11:55:39 +08:00
parent 3db12d6cce
commit 04e6e16a97

View File

@ -33,28 +33,40 @@ Ansible 备忘清单
#### 静态Inventory #### 静态Inventory
`/etc/ansible/hosts` `/etc/ansible/hosts`
```INI ```INI
mail.example.com mail.example.com
[webservers] [webservers]
foo.example.com foo.example.com
bar.example.com bar.example.com
```
Inventory主机组使用多个IP和域名 ### Inventory 主机组使用多个IP和域名
[web]
```
[web]
172.18.12.5[1:4] 172.18.12.5[1:4]
[webservers] [webservers]
www[01:50].example.com www[01:50].example.com
```
Inventory主机组使用子主机组 ### Inventory 主机组使用子主机组
```ini
[usa:children] [usa:children]
southeast southeast
northeast northeast
southwest southwest
northwest northwest
```
给多台主机设置变量 : group variables ### 给多台主机设置变量
`group variables`
如果组中的所有主机共享一个变量值,则可以一次将该变量应用于整个组 如果组中的所有主机共享一个变量值,则可以一次将该变量应用于整个组
```ini
[atlanta] [atlanta]
host1 host1
host2 host2