一、ansible简介
需要在一台机器上搭建ansible环境,且配置目的ip的密码,通道没有问题即可下发命令
使用的通道是ssh(端口:36000)
二、搭建细节
1、安装ansible
yum install -y ansible
2、把目的ip密码写到配置文件中
vim /etc/ansible/hosts
配置文件例如,
[outside_muji]
你的IP ansible_ssh_user=root ansible_ssh_port=36000 ansible_ssh_pass=你的密码
你的IP ansible_ssh_user=root ansible_ssh_port=36000 ansible_ssh_pass=你的密码
3、修改免密登录
vim /etc/ansible/ansible.cfg
在文件中进行搜索定位
:/host_key_checking修改前:
# uncomment this to disable SSH key host checking
#host_key_checking = False
修改后:
# uncomment this to disable SSH key host checking
host_key_checking = False
4、执行你想批量执行的命令
ansible outside_muji -m shell -a "date"