ansible 清單文件定義方法

普通方法定義

[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密碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章