2、修改/etc/ansible/ansible.cfg配置文件(ansible配置文件自动生效)
sudo sed -i.bak ‘s@#remote_port.*22@remote_port = 52113@g‘ /etc/ansible/ansible.cfg
查看 grep remote_port /etc/ansible/ansible.cfg
3、修改/etc/ansible/hosts
cat >/etc/ansible/hosts<< EOF(指定zhenghao这个组都包含哪些主机)
[zhenghao]
172.16.1.41
172.16.1.7
EOF
4、测试
ansible zhenghao -m command -a "hostname"
原文地址:http://blog.51cto.com/13670729/2118790