1.环境检查与安装要求:
- 管理节点需要Python>=2.6,并OpenSSH
- 被管理节点需要python >=2.4,并安装OpenSSH
2.YUM源检查与安装
3.安装ansible
- 使用YUM命令安装Ansible,yum -y install ansible
- 使用pip命令安装Ansible,pip install ansible
4.ansible配置文件 /etc/ansible
- ANSIBLE_CONFIG变量
- 当前目录下./ansible.cfg
- 家目录下~/ansible.cfg
- 配置文件 /etc/ansible/ansible.cfg
5.配置ssh远程连接免密码
ssh-keygen -t rsa -P '' #生成密钥
ssh-keygen -f ~/.ssh/id_rsa -N '' #生成密钥
#配置远程免密(ssh-copy-id不能使用时)
sh-copy-id命令报错:-bash: ssh-copy-id: command not found,安装openssh-client
yum -y install openssh-clients
无法安装时可以用一下方式
cat ~/.ssh/id_*.pub | ssh 被管理服务器ip 'cat >> .ssh/authorized_keys'
#复制密钥到远程主机
for i in ip1 ip2 ip3
do
ssh-copy-id $i
done