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

puppet学习笔记之安装与配置

时间:2015-06-08 19:55:18      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:puppet

Server:


ip=`ifconfig eth0 |grep "inet addr" |awk -F ":" ‘{print $2}‘| awk ‘{print $1}‘`

hostname=`hostname`

echo "$ip    $hostname" >> /etc/hosts


yum -y install gcc ruby ntp


/etc/init.d/ntpd stop

ntpdate cn.pool.ntp.org;hwclock -w


rpm -ivh https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetlabs-release-6-10.noarch.rpm


yum -y install puppet-server


chkconfig puppetmaster on


service puppetmaster start


iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8140 -j ACCEPT

/etc/init.d/iptables save

/etc/init.d/iptables restart


touch /etc/puppet/manifests/site.pp


touch /etc/puppet/manifests/default.pp


touch /etc/puppet/manifests/lamp.pp


echo ‘import "default.pp"‘ >> /etc/puppet/manifests/site.pp


echo ‘import "lamp.pp"‘ >> /etc/puppet/manifests/site.pp


cat <<eof >> /etc/puppet/manifests/default.pp

node ‘default‘ {

        include package::install

}

 

class package::install {

        package { ["nmap","telnet","mlocate","vim-*","wget"]:

                ensure => latest,

                allow_virtual => false,

        }

}

eof


service puppetmaster restart


#puppet cert list --all #查询所有证书;

#puppet cert --sign puppet-agent-XXX #认证;

#sed -i ‘4a \ \ \ \ autosign = true‘ /etc/puppet/puppet.conf    #自动化认证;

#puppet cert revok puppet-agent-XXX #注销证书;

#puppet cert --clean puppet-agent-XXX #删除证书;

#puppet module list     #查看已安装模块;

#puppet module install <module_name>  --version 0.0.0.0 #安装模块;

#puppet module search <search_string> #查找模块;


------------------------------------------------------------------


Client:


#1.设置主机名称;

cat /etc/sysconfig/network | grep -v "^#" | grep "localhost.localdomain" >> /dev/null

if [ $? = 0 ]; then

echo "Your host name is: `hostname`"

read -p "请输入新主机名称:" newhostname

hostname $newhostname

sed -i "s/localhost.localdomain/$newhostname/g" /etc/sysconfig/network

echo "主机名称设置 OK"

echo ""

else

echo "The host name has been changed!"

echo ""

fi


ip=`ifconfig eth0 |grep "inet addr" |awk -F ":" ‘{print $2}‘| awk ‘{print $1}‘`

hostname=`hostname`

echo "$ip    $hostname" >> /etc/hosts


yum -y install gcc ruby ntp


/etc/init.d/ntpd stop

ntpdate cn.pool.ntp.org;hwclock -w


rpm -ivh https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetlabs-release-6-10.noarch.rpm


yum -y install puppet


chkconfig puppet on


echo "192.168.2.180    puppet-master-XXX" >> /etc/hosts


echo "PUPPET_SERVER=puppet-master-XXX" >> /etc/sysconfig/puppet


echo "PUPPET_PORT=8140" >> /etc/sysconfig/puppet


echo "    server = puppet-master-XXX" >>  /etc/puppet/puppet.conf


echo "    runinterval = 5m" >> /etc/puppet/puppet.conf #默认是30m;


service puppet start


#puppet agent --test #申请证书;

#puppet agent -t --sever puppet-master-XXX #立即同步;


本文出自 “方寸小山” 博客,请务必保留此出处http://63638790.blog.51cto.com/513514/1659709

puppet学习笔记之安装与配置

标签:puppet

原文地址:http://63638790.blog.51cto.com/513514/1659709

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