puppet3源码安装脚本
发布时间:2020-12-15 07:12:46 所属栏目:安全 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATHclear;case $1 in'server')PuppetApplication='pup
|
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 #!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
case $1 in
'server')
PuppetApplication='puppetmaster' ;;
'client')
PuppetApplication='puppet' ;;
*)
echo "Usage: $0 [OPTION]"
echo "server puppet server install"
echo "client puppet client install"
exit 1 ;;
esac
PuppetServer="puppetserver.local"
PuppetVersion="puppet-3.4.2"
FacterVersion="facter-1.7.5"
RubyVersion="ruby-2.0.0-p353"
GitVersion="git-1.8.5.4"
OpenSSLVersion="openssl-1.0.1f"
ServerIp="192.168.255.255"
SYSTEM_CHECK(){
[[ $(id -u) != '0' ]] && echo '[Error] Please use root to install PUPPET.' && exit;
egrep -i "centos" /etc/issue && SysName='centos';
egrep -i "ubuntu" /etc/issue && SysName='ubuntu';
[[ "$SysName" == '' ]] && echo '[Error] Your system is not supported this script' && exit;
SysBit='32' && [ `getconf WORD_BIT` == '32' ] && [ `getconf LONG_BIT` == '64' ] && SysBit='64';
}
RUBY_INSTALL(){
cd /tmp
[ ! -f $RubyVersion.tar.gz ] && curl -O ftp://ftp.ruby-lang.org/pub/ruby/$RubyVersion.tar.gz
[ ! -f $OpenSSLVersion.tar.gz ] && curl -O ftp://ftp.openssl.org/source/$OpenSSLVersion.tar.gz
tar xzf $RubyVersion.tar.gz
tar xzf $OpenSSLVersion.tar.gz
cd /tmp/$OpenSSLVersion &&
./Configure linux-x86_64 --shared &&
make && make install
mv /usr/bin/openssl{,.old}
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
cd /tmp/$RubyVersion &&
./configure --with-openssl-dir=/usr/local/ssl --enable-shared &&
make && make install
}
GIT_INSTALL(){
cd /tmp
[ ! -f $GitVersion.tar.gz ] && curl -O https://git-core.googlecode.com/files/$GitVersion.tar.gz
tar zxf $GitVersion.tar.gz
cd /tmp/$GitVersion
./configure
make && make install
}
SYSTEM_BASE_PACKAGES_INSTALL(){
if [ "$SysName" == 'centos' ]; then
echo '[yum-fastestmirror Installing] ************************************************** >>';
yum -y install yum-fastestmirror;
cp /etc/yum.conf /etc/yum.conf.back
sed -i 's:exclude=.*:exclude=:g' /etc/yum.conf
for packages in curl chkconfig gcc make ntp curl-devel zlib-devel perl perl-devel gettext-devel gettext-devel; do
echo "[${packages} Installing] ************************************************** >>";
yum -y install $packages;
done;
mv -f /etc/yum.conf.back /etc/yum.conf;
else
apt-get remove -y ruby;
apt-get update;
for packages in curl chkconfig gcc make ntpdate zlib1g-dev libcurl4-openssl-dev libexpat1-dev gettext libz-dev build-essential; do
echo "[${packages} Installing] ************************************************** >>";
apt-get install -y $packages --force-yes;apt-get -fy install;apt-get -y autoremove;
done;
fi;
ruby -v && RubyOldVersion=`ruby -v |awk '{printf "%sn",$2}'`
[[ "$RubyOldVersion" == '' ]] && RUBY_INSTALL
}
SYSTEM_STEP(){
HostSet=`grep '$PuppetServer' /etc/hosts`
[[ "$HostSet" == "" ]] && echo "$ServerIp $PuppetServer" >> /etc/hosts || sed -i "s/$HostSet/$ServerIp $PuppetServer/g" /etc/hosts
rm -rf /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Chongqing /etc/localtime;
ntpdate -u pool.ntp.org;
[ -s /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config;
}
PUPPET_SOURCE_INSTALL(){
SYSTEM_CHECK && SYSTEM_BASE_PACKAGES_INSTALL && SYSTEM_STEP
cd /tmp
[ ! -f $FacterVersion.tar.gz ] && curl -O https://downloads.puppetlabs.com/facter/$FacterVersion.tar.gz
[ ! -f $PuppetVersion.tar.gz ] && curl -O https://downloads.puppetlabs.com/puppet/$PuppetVersion.tar.gz
tar xzf $FacterVersion.tar.gz
tar xzf $PuppetVersion.tar.gz
cd /tmp/$FacterVersion
ruby install.rb
cd /tmp/$PuppetVersion
ruby install.rb
sudo puppet resource group puppet ensure=present
sudo puppet resource user puppet ensure=present gid=puppet shell='/sbin/nologin'
# SysVol=`lsb_release -a|grep -i codename|awk '{printf "%sn",$2}'`
# wget https://apt.puppetlabs.com/puppetlabs-release-$SysVol.deb
# [ ! -f /tmp/puppetlabs-release-$SysVol.deb ] && echo "This system is not supported this script" && exit 1
# dpkg -i puppetlabs-release-$SysVol.deb
# apt-get update
if [[ "$SysName" == 'centos' ]]; then
[[ "$PuppetApplication" == 'puppetmaster' ]] && cp -af /tmp/$PuppetVersion/ext/redhat/server.init /etc/init.d/$PuppetApplication || cp -af /tmp/$PuppetVersion/ext/redhat/client.init /etc/init.d/$PuppetApplication
else
if [[ "$PuppetApplication" == 'puppetmaster' ]]; then
cp -af /tmp/$PuppetVersion/ext/debian/puppetmaster.init /etc/init.d/$PuppetApplication
cp -af /tmp/$PuppetVersion/ext/debian/puppetmaster.default /etc/default/$PuppetApplication
else
cp -af /tmp/$PuppetVersion/ext/debian/puppet.init /etc/init.d/$PuppetApplication
cp -af /tmp/$PuppetVersion/ext/debian/puppet.default /etc/default/$PuppetApplication
fi
ln -s /usr/local/bin/puppet /usr/bin/puppet
fi
}
PUPPET_SET(){
[ ! -f /etc/puppet/puppet.conf ] && touch /etc/puppet/puppet.conf && echo >/etc/puppet/puppet.conf
cat >/etc/puppet/puppet.conf <<EOF
[main]
server = $PuppetServer
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = $vardir/ssl
[agent]
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
[master]
EOF
if [[ "$PuppetApplication" == 'puppetmaster' ]]; then
sed -i "/main/a certname = $PuppetServer" /etc/puppet/puppet.conf
#sed -i "/master/a autosign = ture" /etc/puppet/puppet.conf
else
sed -i "/agent/a listen = true" /etc/puppet/puppet.conf
sed -i "1 i path /runnauth anynmethod savenallow $PuppetServer" /etc/puppet/auth.conf
fi
chmod +x /etc/init.d/$PuppetApplication
service $PuppetApplication start &&
chkconfig $PuppetApplication on
}
PUPPET_SOURCE_INSTALL && PUPPET_SET
[[ "$PuppetApplication" == 'puppetmaster' ]] && GIT_INSTALL
以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
