ansible hosts配置
阿新 • • 發佈:2018-01-24
python解釋器 連續 參數配置 hosts配置 title -m sudo 變量 inventory
例如 :
[test] # 組名
10.0.0.1 # 主機ip 或者10.0.0.1:65522 自定義端口
別名
s1 ansible_ssh_port=65522 ansible_ssh_host=10.0.0.1 ansible_ssh_user=simon # 別名s1
連續的主機
[g1]
g[1:50].example.com
g[a-f].example.com
- 編輯/etc/ansible/hosts
- 添加本機的public SSH key到目標機器的authorized_keys #ssh-copy-id
- 添加本機的私鑰到Ansible
- 運行ansible all -m ping 測試是否添加成功
[all:vars] # *:vars 塊變量,all:vars 全局變量 ansible_ssh_private_key_file=/root/.ssh/id_rsa ansible_ssh_port=22 ansible_ssh_user=root [t3:vars] # t3 使用python解釋器是python2 ansible_python_interpreter=/usr/bin/python2 nginx_port=80 # 私有變量在playbooks中使用 [t3] 192.168.11.162
ansible hosts配置