puppet的安装

安装配置:

1. Puppet在RedHat/CentOS系 统上安装

Puppet是基于Ruby写成的,所以安装前要准备好Ruby环境。在中心的Server上安装puppet-server包,并运行 puppetmasterd进程;在被管理机上安装puppet包,并运行puppetd进程。另外,在每台主机上配置好自己的hostname,之后每 台机器要以hostname区分。

1). 安装ruby环境:

yum install ruby ruby-rdoc

2). 安装puppet

Server端安装:

 wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

rpm -Uvh epel-release-5-4.noarch.rpm

yum install puppet-server

chkconfig --level 2345 puppetmaster on

修改hosts,添加下面行:

Vi /etc/hosts

192.168.189.134  puppet

192.168.189.133  web1

客户端安装:

 wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

rpm -Uvh epel-release-5-4.noarch.rpm

yum install puppet

chkconfig --level 2345 puppet on

修改hosts,添加下面行:

Vi /etc/hosts

192.168.189.134   puppet

192.168.189.133   web1

3). 启动puppet

Server端首次运行前,编辑/etc/puppet/manifests/site.pp文件,内容可以用最基本的:

# Create “/tmp/testfile” if it doesn’t exist.

class test_class {

file { “/tmp/testfile”:

ensure => present,

mode => 644,

owner => root,

group => root

}

}

# tell puppet on which client to run the class

node web1 {

include test_class

}

启动Server端:

service puppetmaster start

启动客户端:

/etc/init.d/puppet start


最好重启下服务器
init 6


puppet的客户端和服务器是通过ssl链接的,在服务器有一个自签名的根证书,在安
装软件的时候自动生成。注意:要在安装软件以前先设置主机名,因为生成证书的时候
要把主机名写入证书,如果证书生成好了再改主机名,就连不上,这是很多初学者遇到
的问题。每个客户端的证书要经过根证书签名才能和服务器连接。所以首先要在客户端
执行下面的命令来请求服务器签名证书。
puppetd --test --server puppet
产生的信息:
info: Caching catalog for web1.localdomain
info: Applying configuration version '1297250911'
notice: Finished catalog run in 0.04 seconds
执行上面的命令,客户端将生成证书,并且把证书签名请求发到服务器端。登录到服务
器端,执行下面的命令查看是否有客户端的证书请求:
puppetca --list
如果看到了客户端的证书请求,用下面的命令对所有证书请求签名:
puppetca -s -a

 

防火墙和端口设定。puppet服务器端默认使用8140端口监听服务,需要在iptables上开启该端口。                                                 
     iptables  -A INPUT  -p tcp --dport 8140 -j ACCEPT                                                
     请在/etc/sysconfig/iptables 中加入上文的规则,并重启iptables。 

4). 测试:

也可以将日志直接打印到终端上进行测试:

Server端:puppetmasterd -d --no-daemonize -v --trace

客户端:puppetd --test --trace --debug

你可能感兴趣的:(职场,puppet,休闲)