ansible部署,规划
Posted xy51
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible部署,规划相关的知识,希望对你有一定的参考价值。
部署管理服务器
第一步:先检查有没有ssh服务
[[email protected] ~]# rpm -qf /etc/init.d/sshd
openssh-server-5.3p1-118.1.el6_8.x86_64
[[email protected] ~]#
没有的话进行下载
ssh服务部署过程:
yum install -y openssh-server openssh-clients
yum install -y openssh*
第二步: 编写脚本创建公钥分发密钥
[[email protected] .ssh]# vim /data/jiaoben/fenfa.sh
#!/bin/bash
#create keys pair
m -f /root/.ssh/id_dsa*
ssh-keygen -t dsa -f /root/.ssh/id_dsa -N "" -q
yum install -y sshpass
pass_info=123456
# fenfa keys_pub
sshpass -p${pass_info} ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no 10.0.0.1
sshpass -p${pass_info} ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no 10.0.0.2
sshpass -p${pass_info} ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no 10.0.0.3
第三步:
ansible部署(测试上)
a ansible软件安装在管理主机端
yum install -y ansible
说明:ansible软件需要依赖epel源
b ansible受控主机端进行安装
yum install libselinux-python -y
c ansible配置管理文件配置
vim tail -5 /etc/ansible/hosts
[good]
10.0.0.1
10.0.0.2
10.0.0.3