puppet3源码批量安装脚本

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
service iptables stop
puppetserver="puppet"
puppetversion="puppet-3.4.2"
facterversion="facter-1.7.4"
rubyversion="ruby-2.1.0"
PUPPET_INSTALL(){
 cd /tmp
 [ ! -f $rubyversion.tar.gz ] && curl -O http://cache.ruby-lang.org/pub/ruby/$rubyversion.tar.gz
 [ ! -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 $rubyversion.tar.gz
 cd /tmp/$rubyversion
 ./configure
 make
 make install

 tar xzvf $facterversion.tar.gz
 cd /tmp/$facterversion
 ruby install.rb

 tar xzvf $puppetversion.tar.gz
 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'

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
}
PUPPET_SERVER(){
 sed -i "/main/a certname = $puppetserver" /etc/puppet/puppet.conf
 sed -i "/master/a autosign = ture" /etc/puppet/puppet.conf
 cp -af ext/redhat/server.init /etc/init.d/puppetmaster
 chmod +x /etc/init.d/puppetmaster
 service puppetmaster start &&
 chkconfig puppetmaster on
}
PUPPET_CLIENT(){
 sed -i "/agent/a listen = true" /etc/puppet/puppet.conf
 sed -i "1 i path /run\nauth any\nmethod save\nallow $puppetserver" /etc/puppet/auth.conf
 cp -af ext/redhat/client.init /etc/init.d/puppet
 chmod +x /etc/init.d/puppet
 service puppet start &&
 chkconfig puppet on
}
case $1 in
'server')
 PUPPET_INSTALL
 PUPPET_SERVER ;;
'client')
 PUPPET_INSTALL
 PUPPET_CLIENT ;;
esac