ansible 清單檔案定義方法
阿新 • • 發佈:2018-11-25
普通方法定義
[web]
web1
web2
web3
192.168.1.1
192.168.1.2
192.168.1.3
連續名稱定義
[web]
web[1:3]
192.168.1.[1:3]
使用內建變數定義
1. 針對主機的內建變數
[web]
web1 ansible_ssh_pass='123'
web2 ansible_ssh_user='456'
2. 針對組的內建變數
[web]
web1
web2
[web:vars]
ansible_ssh_pass='123'
包含子組的定義
[web]
web1
web2
[nfs]
nfs1
nfs2
[workgroup:children]
web
nfs
Ansible Inventory常用內建變數:
變數名稱 | 用途 |
---|---|
ansible_ssh_host | 定義host ssh地址 |
ansible_ssh_port | 定義host ssh埠 |
ansible_ssh_user | 定義host ssh 認證使用者 |
ansible_ssh_pass | 定義ssh認證密碼 |
ansible_sudo | 定義sudo使用者 |
ansible_sudo_pass | 定義sudo密碼 |