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