ansible一键部署脚本-洪总分享
!/bin/bash
function:ansible自动部署
author:999vip 20211119
yum install epel-release -y
mv epel.repo epel.repo.bak >> /dev/null
yum clean all && yum makecache
rpm -Uvh http://mirrors.ustc.edu.cn/epel/epel-release-latest-7.noarch.rpm
yum install epel-release -y
yum install ansible -y
echo ansible部署完成,接下来进行主机组配置
echo 请输入主机组名称
read a
sed -i '12 s/^/['$a']n/' /etc/ansible/hosts
echo 请输入将要加入$a主机组的ip
read b
sed -i '13 s/^/['$b']n/' /etc/ansible/hosts
ssh-keygen -f /root/.ssh/id_rsa -N ''
ssh-keyscan -H $b >> ~/.ssh/known_hosts
echo 现在部署免密登录
echo 请输入$b主机的密码
ssh-copy-id -i /root/.ssh/id_rsa.pub $b
function:ansible自动部署
author:999vip 20211119
yum install epel-release -y
mv epel.repo epel.repo.bak >> /dev/null
yum clean all && yum makecache
rpm -Uvh http://mirrors.ustc.edu.cn/epel/epel-release-latest-7.noarch.rpm
yum install epel-release -y
yum install ansible -y
echo ansible部署完成,接下来进行主机组配置
echo 请输入主机组名称
read a
sed -i '12 s/^/['$a']n/' /etc/ansible/hosts
echo 请输入将要加入$a主机组的ip
read b
sed -i '13 s/^/['$b']n/' /etc/ansible/hosts
ssh-keygen -f /root/.ssh/id_rsa -N ''
ssh-keyscan -H $b >> ~/.ssh/known_hosts
echo 现在部署免密登录
echo 请输入$b主机的密码
ssh-copy-id -i /root/.ssh/id_rsa.pub $b
上一技术:for循环:主机状态检查
下一技术:redis一键部署脚本-洪总分享