本文共 512 字,大约阅读时间需要 1 分钟。
1、准备ansible 环境
前提是要创建好管理机和被管理机地ssh密钥认证,如果禁止root远程登陆地话,要给普通用户sudo权限。1)管理机yum install -y ansible2)被管理机yum libselinux-phython -y2、修改/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.cfg3、修改/etc/ansible/hosts
cat >/etc/ansible/hosts<< EOF(指定zhenghao这个组都包含哪些主机)[zhenghao]172.16.1.41172.16.1.7EOF4、测试
ansible zhenghao -m command -a "hostname"转载于:https://blog.51cto.com/13670729/2118790