之前写过在centos部署salt.公司线上有少部分Ubuntu服务器。今天安装一下,比centos安装更简便。
apt-get install python-software-properties
add-apt-repository ppa:saltstack/salt
apt-get update
2.安装salt
apt-get install salt-minion -y //此处我是部署客户端,安装master参考此命令即可
3.编辑配置文件
sed -i 's/#master/master '服务端IP'/' /etc/salt/minion
sed -i "/#master_finger:/a master_finger: '3d:06:7c:14:af:6e:0a:3b:12:00:15:25:19:54:fe:d6'" /etc/salt/minion
sed -i "/#id:/a id: $ip" /etc/salt/minion //$ip即客户端IP
4.启动服务
service salt-minion restart
踩了个坑写了个脚本
//脚本中的ip:1.2.3.4请替换成服务器端master的ip,master_finger也设置成自己生成的地址
#!/bin/bash
function install_minion() {
CentOS=`cat /etc/issue | grep 'CentOS'`
Ubuntu=`cat /etc/issue | grep 'Ubuntu'`
####============= centos install ===========###########
if [ -n "$CentOS" ];then
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el6.noarch.rpm > /tmp/install.log
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-6.noarch.rpm > /tmp/install.log
yum clean expire-cache > /tmp/install.log
#yum update -y
yum install -y salt-minion > /tmp/install.log
service iptables stop > /tmp/install.log
chkconfig salt-minion on
fi
####============= ubuntu install ===========###########
if [ -n "$Ubuntu" ];then
apt-get install python-software-properties -y > /tmp/install.log
add-apt-repository ppa:saltstack/salt > /tmp/install.log
apt-get update -y > /tmp/install.log
apt-get install salt-minion -y > /tmp/install.log
fi
####============= write hosts ===========###########
grep '1.2.3.4' /etc/hosts
if [ $? != 0 ];then
echo '1.2.3.4 salt' >> /etc/hosts
fi
####============= set /etc/salt/minion ===========###########
sed -i "/#master_finger:/a master_finger: '3d:06:7c:14:af:6e:0a:3b:12:00:15:25:19:54:fe:d8'" /etc/salt/minion ##master_finger识别
#ip=`ifconfig eth0 |awk '/inet addr/{gsub(/addr:/,"");print $2}'`
#ip=`ifconfig | awk '/inet/{print $2}'|awk -F: '{print $2}'|egrep -v '(127.0.0.1|^$|192.168.*|10.*)'|awk 'NR==1'`
ip=`hostname -I|awk '{print $1}'`
sed -i "/#id:/a id: $ip" /etc/salt/minion
####============= start server ===========###########
service salt-minion restart
}
function install_master() {
CentOS=`cat /etc/issue | grep 'CentOS'`
Ubuntu=`cat /etc/issue | grep 'Ubuntu'`
####============= centos install ===========###########
if [ -n "$CentOS" ];then
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el6.noarch.rpm > /tmp/install.log
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-6.noarch.rpm > /tmp/install.log
yum clean expire-cache > /tmp/install.log
#yum update -y > /tmp/install.log
yum install -y salt-matser > /tmp/install.log
service iptables stop > /tmp/install.log
service salt-master restart
fi
####============= ubuntu install ===========###########
if [ -n "$Ubuntu" ];then
apt-get install python-software-properties > /tmp/install.log
add-apt-repository ppa:saltstack/salt > /tmp/install.log
apt-get update -y > /tmp/install.log
apt-get install salt-master -y > /tmp/install.log
fi
}
read -p "Please input which install:(salt-master|salt-minion) " i
sleep 1
case $i in
salt-master)
install_master
;;
salt-minion)
install_minion
;;
*)
echo -n "it's error input!"
exit 0
;;
esac
本文由 Mr Gu 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Sep 23, 2016 at 01:13 pm