Ansible直接執行遠程命令,不用ssh登錄交互執行。shell
以下:網絡
ansible all -i 192.168.199.180, -m shell -a "ifconfig" -u supermap
參數解釋:ssh
主機文件格式,樣例參考( host-list):工具
[local] 192.168.199.173 ansible_ssh_port=22 ansible_ssh_host=192.168.199.173 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap 192.168.199.180 ansible_ssh_port=22 ansible_ssh_host=192.168.199.180 ansible_ssh_user=supermap ansible_ssh_pass=SuperMap 192.168.199.249 ansible_ssh_port=22 ansible_ssh_host=192.168.199.249 ansible_ssh_user=openswitch ansible_ssh_pass=SuperMap
使用主機文件,自動登陸後,批量執行命令:.net
ansible all -i host-list -m shell -a "ifconfig" -u my-username
這個仍是很方便的。code
參考:blog