一、配置Puppetmaster
在第一部分中我们在centos 5.6 64bit安装puppetmaster 和puppetd 软件包,现在我们配置一个基于c/s 模型,在服务端将/etc/resolv.conf 自动分发到 客户端
1.1创建你的第一个模型
我们的第一个模型叫networking::resolver, 它将推送一个 resolv.conf 到客户端
在/etc/puppet 创建我们的目录体系
- # cd /etc/puppet
- # mkdir {modules,files}
- # mkdir modules/networking/{files,mainfests}
1.2创建 resolv.conf
# vim modules/networking/files/resolv.conf
- nameserver 202.106.0.20
- nameserver 202.102.128.68
创建你的 mainfest模型
# vim modules/networking/manifests/init.pp
- class networking {
- }
- class networking::resolver inherits networking {
- file { "/etc/resolv.conf":
- ensure => present,
- source => "puppet:///modules/networking/resolv.conf",
- group => "root",
- owner => "root",
- mode => "0755"
- }
- }
1.3 配置你的站点 和节点
创建一个 最小化的站点文件
# vi manifests/site.pp
- import "nodes"
- import "templates"
- filebucket { main: server => puppet }
- Create a tempates file
- # vi manifests/templates.pp
- class baseclass {
- include networking::resolver
- }
- node default {
- include baseclass
- }
1.4 创建你的节点文件
不要忘了在将puppetmaser替换为你自己的主机名
# vi manifests/nodes.pp
- node 'basenode' {
- include baseclass
- }
- node 'puppetmaster' inherits basenode {
- }
二、设置puppetmaster 属性
2.1 创建默认配置文件(yum安装后,就有了下面的配置文档)
# vi puppet.conf
- [main]
- # The Puppet log directory.
- # The default value is '$vardir/log'.
- logdir = /var/log/puppet
- # Where Puppet PID files are kept.
- # The default value is '$vardir/run'.
- rundir = /var/run/puppet
- # Where SSL certificates are kept.
- # The default value is '$confdir/ssl'.
- ssldir = $vardir/ssl
- [agent]
- # The file in which puppetd stores a list of the classes
- # associated with the retrieved configuratiion. Can be loaded in
- # the separate ``puppet`` executable using the ``--loadclasses``
- # option.
- # The default value is '$confdir/classes.txt'.
- classfile = $vardir/classes.txt
- # Where puppetd caches the local configuration. An
- # extension indicating the cache format is added automatically.
- # The default value is '$confdir/localconfig'.
- localconfig = $vardir/localconfig
- report = true
- [master]
- autosign = true
2.2 为你的文件服务器设置权限
# vi fileserver.conf
- [files]
- path /etc/puppet/files
- allow *
- [modules]
- allow *
- [plugins]
- allow *
2.3 启动puppetmaster
# service puppetmaster start
- Starting puppetmaster: [ OK ]
三。配置puppet 客户端
在客户端服务器上,编辑你的puppet.conf,在[agen]部分添加下列内容,注意将puppetmaster 替换你的主机名
# vi /etc/puppet/puppet.conf
- [agent]
- server = puppetmaster
- report = true
- listen = true
四、设置 puppetrunner
创建一个叫namspaceauth.conf 文件,并添加下列的内容。
# vi /etc/puppet/namespaceauth.conf
- [puppetrunner]
- allow *
4.1 启动 puppetd
# service puppet start
五、测试puppet客户端和服务端是否正常通信
- # puppetd --server puppetmaster --test
- --- /etc/resolv.conf 2011-09-08 20:14:03.000000000 +0800
- +++ /tmp/puppet-file.30611.0 2011-09-09 17:49:26.000000000 +0800
- @@ -1,2 +1 @@
- nameserver 202.106.0.20
- -nameserver 202.106.196.115
- info: FileBucket adding {md5}d7ee49734e75e85345c70a702c69332c
- info: /Stage[main]/Networking::Resolver/File[/etc/resolv.conf]: Filebucketed /etc/resolv.conf to puppet with sum d7ee49734e75e85345c70a702c69332c
- notice: /Stage[main]/Networking::Resolver/File[/etc/resolv.conf]/content: content changed '{md5}d7ee49734e75e85345c70a702c69332c' to '{md5}45c56312b1256329a125ee86b1a68dd1'
- notice: Finished catalog run in 0.18 seconds
下一节,将讲解puppet dashboard的安装配置。