Ansible-搭建

Ansible部署
系统环境:CentOs7.2
服务端:192.168.4.183
服务端:192.168.4.184
服务端:192.168.4.185
1. 客户端和服务端需要统一openssl、ssh版本
[root@localhost ~]# yum -y install openssl openssh
2. Ansible安装 #服务端
[root@localhost ~]# yum -y install epel-release #安装epel源
[root@localhost ~]# yum -y install ansible #安装组件
3. 配置主机组
[root@localhost ~]# vim /etc/ansible/hosts
[cwg]
192.168.4.183
192.168.4.184
192.168.4.185
4. 生成公钥私钥
[root@localhost ~]# ssh-keygen -t rsa -P ''
5. 公钥分发客户端上
[root@localhost ~]# cd /root/.ssh/
[root@localhost ~]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys ---- 生成一个新密钥authorized_keys
6. 把authorized_keys传给要控制的主机
[root@localhost ~]# cd /root/.ssh/
[root@localhost ~]# scp authorized_keys 客户端用户@客户端IP:/root/.ssh/
7. 客户端更改公钥权限 #客户端
chmod 600 /root/.ssh/authorized_keys #传过去之后更改权限
8. 用ansible测试远程主机的运行状态
ansible cwg -m ping
 
本文来自 http://note.youdao.com/noteshare?id=1f257f7ee3f7d3c4802863cb0d3e981b

猜你喜欢

转载自www.cnblogs.com/98years/p/9008862.html