操作环境:linux系统
操作IP:
192.168.211.130 (安装ansible)
192.168.211.132
192.168.211.137
1.执行命令 : yum install ansible -y
出现报错:
No package ansible available.
Error: Nothing to do
2.需要安装两个插件
yum -y install epel-release
yum -y install vconfig -y
3. 步骤2的两个插件安装成功后,再执行:yum install ansible -y
即可安装成功
4.做一个简单的操作:
vi /etc/ansible/hosts
备注:
[nihao] 是nihao组(名字可以随便起)
格式:IP 端口号 账户 密码
5.执行命令:ansible nihao -m shell -a "ifconfig|grep in"
即可查出 组:[nihao]的IP信息
错误:
1. 如出现:Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host.
处理办法:
vi /etc/ansible/ansible.cfg
:/host_key_checking
找到后,把#host_key_checking = False 前面的#去掉
保存退出即可。