Chinaunix首页 | 论坛 | 博客
  • 博客访问: 528385
  • 博文数量: 81
  • 博客积分: 8020
  • 博客等级: 中将
  • 技术积分: 1085
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-08 10:36
文章分类

全部博文(81)

文章存档

2010年(3)

2009年(25)

2008年(53)

我的朋友

分类: LINUX

2008-08-28 15:06:08

配制文件将不定期更新
三台服务器:
1、服务器1:10.129.60.138 hostname centos
2、客户端1:10.129.60.22 hostname jira
3、客户端2:10.129.60.29 hostname nagios

注意:三台机器的名称解析无论是正向还是反向都要一一对应,不能错误。

一、中心配制服务器(10.129.60.138)
服务器除了作为中心配制服务器外,也象其它客户端一样执行cfagent。
1、/masterfile/inputs/update.conf
# update.conf
classes:
        have_ppkeys = ( FileExists(/var/cfengine/ppkeys/localhost.priv) )

control:
        actionsequence = ( copy processes shellcommands tidy )
        domain = ( domain.com )
        policyhost = ( 10.129.60.138 )
        master_cfinput = ( /masterfile/inputs )
        workdir = ( /var/cfengine )
        Syslog = ( off )

copy:
    $(master_cfinput) dest=$(workdir)/inputs
                      r=inf
                      mode=700
                      type=binary
                      server=$(policyhost)
                      trustkey=true

processes:
        "cfservd" signal=term restart "${workdir}/bin/cfservd"
        "cfenvd" signal=term restart "${workdir}/bin/cfenvd -H"
        "cfexecd" signal=term restart "${workdir}/bin/cfexecd"

shellcommands:
        !have_ppkeys::
        ${workdir}/bin/cfkey

tidy:
        $(workdir)/outputs pattern=* age=7
# End

2、/masterfile/inputs/cfservd.conf
# cfservd.conf

control:
    cfrunCommand = ( "/var/cfengine/bin/cfagent" )
    domain = ( domain.com )
    AllowConnectionsFrom = ( 10.129.60.0/24 )
    TrustKeysFrom = ( 10.129.60.0/24 )
    AllowUsers = ( root )
    MaxConnections = ( 150 )
    MultipleConnections = ( true )

admit:
    /masterfile/inputs    10.129.60.
    /var/cfengine         10.129.60.

3、/masterfile/inputs/cfagent.conf(测试根据不同的分组完成不同的操作,注意在服务器的/masterfile/inputs下建立目录svn_servers和bug_servers,并在svn_servers下建立svn_test文件,bug_servers下建立bug_test文件)
control:
        actionsequence = ( copy editfiles files disable tidy )
        schedule = ( Min00_05 Min30_35 )
        smtpserver = ( mail.domain.com )
        EmailFrom = ( cfengine@centos )
        sysadm = ( xiaowei@doamin.com )
        EmailMaxLines = ( 0 )
        ChecksumUpdates = ( on )
        IfElapsed = ( 0 )
        timezone = ( CST )
        day_of_week = ( ExecResult(/bin/date +%a) )
        configroot = ( /var/cfengine/inputs )
        cfinputs_version = ( 1.0.1 )

copy:
        Hr01.OnTheHour::
                /etc dest=/usr/local/backup/${day_of_week}/etc purge=true r=inf

editfiles:
        { /etc/crontab
          AppendIfNoSuchLine "0 * * * * root /var/cfengine/bin/cfexecd -F"
        }

files:
        /etc/passwd m=644 o=root action=fixall checksum=md5
        /etc/shadow m=600 o=root action=fixall
        /etc/group  m=644 o=root action=fixall
        /tmp m=1777 action=fixdirs

groups:
        svn_servers = ( nagios )
        bug_servers = ( jira )

disable:
        /root/.rhosts
        /etc/hosts.equiv

tidy:
        /tmp recurse=inf age=7 rmdirs=sub

import:
        any::
                files.cf

4、/masterfile/inputs/files.cf
control:
         actionsequence = ( copy shellcommands )
copy:
        svn_servers::
                   $(configroot)/svn_servers/svn_test dest=/home/svn_test m=644 o=root g=root verify=true r=inf
        bug_servers::
                   $(configroot)/bug_servers/bug_test dest=/home/bug_test m=644 o=root g=root verify=true r=inf
shellcommands:
        svn_servers::
                   "/bin/echo hello svn!"
        bug_servers::
                   "/bin/echo hello bug!"

5、/var/cfengine/inputs/cfrun.hosts
domain=domain.com
10.129.60.138
10.129.60.29
10.129.60.22

将/masterfile/inputs/update.conf文件拷贝到/var/cfengine/inputs,执行/var/cfengine/bin/cfagent -v,/masterfile/inputs/下的所有文件将被被拷贝到/var/cfengine/inputs,并执行相应的操作,如启动cfserd、cfenvd和cfexecd等。


二、客户端(10.129.60.22、10.129.60.29配制文件相同)
将/masterfile/inputs/update.conf文件拷贝到/var/cfengine/inputs,执行/var/cfengine /bin/cfagent -v,cfagent从中心配制服务器10.129.60.138上将/masterfile/inputs/下的所有文件将被被拷贝到本地/var/cfengine/inputs,并执行相应的操作,如启动 cfserd、cfenvd和cfexecd等
阅读(1200) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~