puppetの自動インストールスクリプトのアップデート

ファイル名:puppet.sh
サンプルコード:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
puppetserver="puppet"
puppetversion="puppet-3.4.2″
facterversion="facter-1.7.4″
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
#システム内容のチェック
SYSTEMCHECK(){
[ $(id -u) != '0’ ] && echo '[エラー:] root権限でPUPPETをインストール.’ && exit;
egrep -i “centos" /etc/issue && SysName=’centos’;
egrep -i “ubuntu" /etc/issue && SysName=’ubuntu’;
[ “$SysName" == " ] && echo '[エラー:] あなたのシステムはこのスクリプトをサポートしません’ && exit;
#SysBit=’32’ && [ `getconf WORD_BIT` == ’32’ ] && [ `getconf LONG_BIT` == ’64’ ] && SysBit=’64’;
}
SYSTEMSTEP(){
rm -rf /etc/localtime;
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;
echo '[ntp Installing] ******************************** >>’;
[ “$SysName" == 'centos’ ] && yum install -y ntp || apt-get install -y ntpdate;
ntpdate -u pool.ntp.org;
[ -s /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config;
}

PUPPET_INSTALL(){
SYSTEMCHECK
SYSTEMSTEP
cd /tmp
if [ “$SysName" == 'centos’ ]; then
yum -y install yum-fastestmirror;
for packages in ruby ruby-libs ruby-shadow; do
echo “[${packages} Installing] ************************************************** >>";
yum -y install $packages;
done;
[ ! -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 xzvf $facterversion.tar.gz
tar xzvf $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’

else
SysVol=`lsb_release -a|grep -i codename|awk '{printf “%s\n",$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
fi
if [ “$PuppetApplication" == 'puppetmaster’ ]; then
[ “$SysName" == 'centos’ ] && cp -af ext/redhat/server.init /etc/init.d/$PuppetApplication || apt-get install -y puppetmaster-passenger
else
[ “$SysName" == 'centos’ ] && cp -af ext/redhat/client.init /etc/init.d/$PuppetApplication || apt-get install -y puppet
fi
}
PUPPET_SET(){
[ ! -f /etc/puppet/puppet.conf ] && touch /etc/puppet/puppet.conf && echo >/etc/puppet/puppet.conf
cat >/etc/puppet/puppet.conf <

Source

Posted by arkgame