puppet安装脚本

 linux  puppet   2016-11-01 

#!/bin/bash
#@Author:www.saintic.com
#@Description:Install puppet master or agent

clear
echo -e -n "\033[32m请输入1安装puppet master,输入2安装puppet client如果出现error.log文件,请注意查看.\033[0m"
read CODE_NUM

function HEAD() {
    if [ $(id -u) != "0" ]; then
        echo "Error:请确保以root用户执行此脚本!"
        exit 1
    fi
    SESTATE=$(sestatus | wc -l)
    if [ "$SESTATE" != "1" ]; then
        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
        sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config &> /dev/null
    fi
}

function error() {
    echo "Error:Please check this script and input/output!"
}

iAGENT() {
    yum install -y puppet facter openssl-devel  2>> error.log
    chkconfig puppet on
}
iMASTER() {
    yum install -y puppet puppet-server facter openssl-devel  2>> error.log
    chkconfig puppetmaster on
}
startINSTALL() {
    if [ "$CODE_NUM" = "1" ]; then
        iMASTER
        iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8140 -j ACCEPT
    else
        iAGENT
        iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8139 -j ACCEPT
    fi
}

infoVERSION() {
grep "5" /etc/redhat-release &> /dev/null && echo $? > v5
grep "6" /etc/redhat-release &> /dev/null && echo $? > v6
grep "7" /etc/redhat-release &> /dev/null && echo $? > v7
if [ `cat v5` = "0" ]; then
    rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm
    startINSTALL
    service iptables save
fi
if [ `cat v6` = "0" ]; then
    rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
    startINSTALL
    service iptables save
fi
if [ `cat v7` = "0" ]; then
    rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
    startINSTALL
    #firewall-cmd --permanent --zone=public --add-port=8140/tcp
    #firewall-cmd --reload
    systemctl stop firewalld ; systemctl disable firewalld
fi
rm -f v5 v6 v7 &> /dev/null
}

HEAD && infoVERSION || exit 1


点赞 打赏
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

交流分享

QQ扫一扫或点击二维码加入,群号577543189
微信扫一扫,手滑关注它
微信扫一扫,进入小程序

推荐文章

标签云集

友情链接  交换友链

推广位