#!/bin/bash saltmaster=192.168.0.10 saltminionNane=$2 InitSaltEvn() { yum install wget -y wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm } InstallSaltMinion() { if [ $# -ne 2 ]; then echo $# echo "explame installsalt.sh minion minionName" exit 0 fi InitSaltEvn yum install salt-minion -y result=$? if [ $result -gt 0 ]; then echo "Repeat excute install salt minion ********************" yum install salt-minion -y fi filename=/etc/salt/minion if [ ! -f $filename ]; then echo "Yum install salt-minion failed ! pleaease excute again this script" exit 0; fi sed -i "s/#master: salt/master: $saltmaster/g" /etc/salt/minion sed -i "s/#id:*/id: $saltminionNane/g" /etc/salt/minion chkconfig --level 345 salt-minion on service salt-minion start } InstallSaltMaster() { InitSaltEvn yum install salt-master -y resut=$? if [ $result -lg 0 ] ;then echo "Repeat excute install salt master ********************" yum install salt-master -y fi chkconfig --level 345 salt-master on service salt-master start } case "$1" in minion) InstallSaltMinion $@ && exit 0 ;; master) InstallSaltMaster || exit 0 ;; *) echo $"Usage: $0 {master|minion}" exit 2 esac
转载于:https://blog.51cto.com/lizhuan/1836815