码迷,mamicode.com
首页 > 其他好文 > 详细

Saltstack客户端安装脚本

时间:2017-03-03 19:40:54      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:salt客户端脚本安装

脚本注释:

PS:用PYTHON2.6的master

#!/bin/sh

source /etc/profile

yum list installed | grep salt-minion

install_status=`echo $?`

localhostname=`hostname`

if [ $install_status == 0 ];then

        saltid=`cat /etc/salt/minion | grep -v ‘#‘ | grep id | sed ‘s/id: //g‘`

        if [ "$saltid" == "$localhostname" ];then

                service salt-minion status

        runstatus=`echo $?`

                if [ $runstatus != 0 ];then

            echo "salt-minion is running"

                        exit 0

                else

                        service salt-minion start

                        service salt-minion status

            runstatus=`echo $?`

                        if [ $runstatus == 0 ];then

                echo "salt-minion start sucessfully"

                                exit 0

                        else

                echo "salt-minion start fail"

                                exit 0

                        fi

                fi

        else

                mv /etc/salt/minion /etc/salt/minion_bak

                echo "id: "$localhostname >> /etc/salt/minion

                echo "user: root" >> /etc/salt/minion

                echo "master : 10.7.7.180" >> /etc/salt/minion

                echo "master_port: 4506" >> /etc/salt/minion

                echo "backup_mode: minion" >> /etc/salt/minion

                echo "output: nested" >> /etc/salt/minion

                echo "acceptance_wait_time: 10" >> /etc/salt/minion

                echo "acceptance_wait_time_max: 0" >> /etc/salt/minion

                echo "random_reauth_delay: 60" >> /etc/salt/minion

                service salt-minion status

        runstatus=`echo $?`

                if [ $runstatus == 0 ];then

                        service salt-minion restart

                        service salt-minion status

            runstatus=`echo $?`

                        if [ $runstatus == 0 ];then

                echo "salt-minion restart sucessfully"

                                exit 0

                        else

                echo "salt-minion restart fail"

                                exit 0

                        fi

                else

                        service salt-minion start

                        service salt-minion status

            runstatus=`echo $?`

                        if [ $runstatus == 0 ];then

                echo "salt-minion start sucessfully"

                                exit 0

                        else

                echo "salt-minion start fail"

                                exit 0

                        fi

                fi

        fi

else

        rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

        yum install -y salt-minion

        mv /etc/salt/minion /etc/salt/minion_bak

        echo "id: "$localhostname >> /etc/salt/minion

        echo "user: root" >> /etc/salt/minion

        echo "master : 10.7.7.180" >> /etc/salt/minion

        echo "master_port: 4506" >> /etc/salt/minion

        echo "backup_mode: minion" >> /etc/salt/minion

        echo "output: nested" >> /etc/salt/minion

        echo "acceptance_wait_time: 10" >> /etc/salt/minion

        echo "acceptance_wait_time_max: 0" >> /etc/salt/minion

        echo "random_reauth_delay: 60" >> /etc/salt/minion

        service salt-minion start

        service salt-minion status

    runstatus=`echo $?`

        if [ $runstatus == 0 ];then

        echo "salt-minion start sucessfully"

                exit 0

        else

        echo "salt-minion start fail"

                exit 0

        fi

fi

技术分享


本文出自 “无法长大” 博客,请务必保留此出处http://tfbaby.blog.51cto.com/3125450/1902972

Saltstack客户端安装脚本

标签:salt客户端脚本安装

原文地址:http://tfbaby.blog.51cto.com/3125450/1902972

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!