SlideShare a Scribd company logo
Cfengine V2  主讲人:刘天斯
什么是 Cfengine?  Cfengine ( 配置引擎 ) 是一种  UNIX 分布式系统管理实用程序 ,其目的是使简单的管理的任务自动化,使困难的任务变得较容易。它的目标是使系统任何状态收敛到一种理想状态。它适用于所有基于 UNIX 或类 UNIX 的操作系统,并且它可以通过 UNIX 兼容的环境 / 库  Cygwin  在较新版本的 Windows 操作系统中运行。
Cfengine 可以做什么 ? ♦  完成后期安装任务,例如配置网络界面信息。 ♦  编辑系统配置文件以及其它文件。 ♦  建立信号连接。 ♦  检验、更正文件许可及所有权。 ♦  删除无用文件。 ♦  压缩被选文件。 ♦  在网络中分发文件。 ♦  自动挂载 NFS 文件系统。 ♦  检查重要文件和文件系统是否存在及其完整性。 ♦  执行命令及脚本。 ♦  应用安全相关的补丁以及相似系统的修正。 ♦  管理系统服务器进程。
Cfengine  安装 mkdir -p /home/setup cd /home/setup wget http://192.168.100.247/cfengine/cfengine-2.2.5.tar.gz tar -zxvf cfengine-2.2.5.tar.gz && cd cfengine-2.2.5 ./configure  make  && make install /usr/local/sbin/cfagent -v /usr/local/sbin/cfkey /usr/local/sbin/cfexecd /usr/local/sbin/cfservd cp /usr/local/sbin/cfagent /var/cfengine/bin cp /usr/local/sbin/cfenvd /var/cfengine/bin cp /usr/local/sbin/cfexecd /var/cfengine/bin cp /usr/local/sbin/cfservd /var/cfengine/bin mkdir -p /var/cfengine/masterfile/inputs echo "/var/cfengine/bin/cfservd" >> /etc/rc.local echo "/var/cfengine/bin/cfenvd -H" >> /etc/rc.local echo "iptables -A INPUT -s 192.168.0.0/16 -p tcp --dport 5308 -j ACCEPT" >> /etc/firewall.sh /var/cfengine/bin/cfagent -v
Cfengine  的组成部分 ♦  Cfagent :  解释策略的承诺并且以收敛的方式执行它们。代理可使用由统计监测引擎 Cfenvd 产生的数据,并且它能从运行于本地或远程主机上的 Cfenvd 中获取数据。 ♦  Cfexecd :  执行 Cfagent ,并且记录它的输出(可选择通过电子邮件寄出摘要)。它可 以在一个后台程序( standalone )的模式下运行,或者可以通过 cron  在一个类似于 Unix  的系统上运行。 ♦  Cfservd :  监控 Cfengine  的端口:提供文件数据,并在接收一个来自 cfrun  的连接的 基础上启动 Cfagent 。请注意,没有数据可以通过这个后台程序。 ♦  Cfrun :  联接远程主机,并要求他们运行 cfagent 。 ♦  Cfenvd :  收集在每台主机上使用资源的统计数据,用于异常状况的检测。信息以 cfengine  类的形式被代理获得,因此代理可以及时地对异常的动态状况进行检查并 作出反应。 ♦  Cfkey :  在主机生成“公有 - 私有”密钥对。一般作为 Cfengine  软件安装过程中的一 个步骤,你只需运行一次该程序。 ♦  Cfshow :  一旦你对它的内部存储感兴趣, cfshow  便将 cfagent  的数据库内容以 ASCII 的格式导入。 ♦  Cfenvgraph :  将 Cfenvd  的数据库内容导入为一种可用于图标格式显示一台主机在 其环境中的一般行为。
Cfengine  组成部分之间的联系 1 )服务器上运行 cfrun,cfrun 会根据 cfrun.hosts 中的主机列表来连接到某个客户机的 cfservd 程序 2 )客户机上 cfservd 调用本机的 cfagent 程序 3 )客户机上 cfagent 程序执行 update.conf, 连接到中央机的 cfservd 复制下载策略文件 cafagent.conf 4 )客户机下载成功后执行最新版本的策略文件 , 不成功就执行旧版本的 .
Cfengine  操作符 groups( 组合 ) control( 控制 ) homeservers( 主服务器 ) binservers( 执行文件服务器 ) mailserver( 邮件服务器 ) mountables( 挂载表 ) import( 导入 ) broadcast( 广播 ) resolve( 解析 ) defaultroute( 默认路由 ) directories( 目录 ) miscmounts( 杂项挂载 ) files( 文件 ) ignore( 忽略 ) tidy( 整理 ) required( 必需 ) links( 链接 ) disable( 禁用 ) shellcommands(shell 命令 ) editfiles( 编辑文件 ) processes( 过程 )
Cfengine 策略文件 cfservd.conf control: domain = ( google.cn ) #add by liuts cfrunCommand = ( "/usr/local/sbin/cfagent" ) DenyBadClocks = ( false ) #add by liuts MaxConnections = ( 1000 ) AllowConnectionsFrom  = ( 192.168.0.0/16 ) #  AllowMultipleConnectionsFrom = ( 192.168.0 ) TrustKeysFrom  = ( 192.168.0.0/16 ) AllowUsers = ( root ) MultipleConnections = ( true ) ######################################################### admit:  # or grant: #add by liuts /var/cfengine/masterfile/inputs  192.168.0.0/16 /usr/local/sbin  192.168.0.0/16 /var/cfengine  192.168.0.0/16 /bin  192.168.0.0/16 /etc  192.168.0.0/16
Cfengine 策略文件 update.conf # update.conf control: actionsequence = ( copy processes tidy ) domain = ( google.cn ) #policyhost = ( my_policy_host ) policyhost = ( cfengine.server.com ) master_cfinput = ( /var/cfengine/masterfile/inputs ) workdir = ( /var/cfengine ) copy: $(master_cfinput) dest=$(workdir)/inputs r=inf mode=700 type=binary server=$(policyhost) trustkey=true processes: "cfservd"  restart /usr/local/sbin/cfservd "cfenvd"  restart "/usr/local/sbin/cfenvd -H" tidy: $(workdir)/outputs pattern=* age=7 # End
Cfengine 策略文件 cfagent.conf ( 一 ) control: access = ( root ) actionsequence = ( resolve copy files editfiles shellcommands ) domain  = ( goolge.cn ) timezone  = ( CST ) smtpserver  = ( smtp.gmail.com )  # used by cfexecd sysadm  = ( liutiansi@gmail.com )  # where to mail output EmptyResolvConf = ( true ) #  listing = ( ExecResult("/bin/date -s 2008-04-30") ) ###################################################################### resolve: 8.8.8.8 ###################################################################### copy: /etc/passwd dest=/etc/passwd  server=cfengine.server.com trustkey=true /etc/shadow dest=/etc/shadow server=cfengine.server.com trustkey=true ######################################################################
Cfengine 策略文件 cfagent.conf ( 二 ) files: /etc/passwd  mode=644  owner=root action=fixall checksum=md5 /etc/shadow mode=600 owner=root action=fixall ###################################################################### editfiles: { /home/config.txt AutoCreate AppendIfNoSuchLine "welcome to tianya.cn" } ###################################################################### shellcommands: "/bin/echo 'welcomesystem' > /var/cfengine/inputs/info.log" "/bin/echo $(listing) $(listing1)" ###################################################################### processes: "inetd"  signal=hup "irc"  signal=kill
Cfengine 策略文件 (cfrun.hosts) # # This is the host list for cfrun # # Only these hosts will be contacted by remote connection # access=root 192.168.100.51 192.168.100.52 192.168.100.53 192.168.100.54 192.168.100.55 192.168.100.60 192.168.100.67 192.168.100.109 192.168.100.110 192.168.100.111 192.168.100.112 192.168.100.113 192.168.100.114
Cfengine  之 control ( 类、方法、变量、表达式 ) Hard class: ultrix, sun4, sun3, hpux, hpux10, aix, solaris, osf, irix4, irix, irix64 sco, freebsd, netbsd, openbsd, bsd4_3, newsos, solarisx86, aos,nextstep, bsdos, linux, debian, cray,unix_sv, GnU, NT Time class : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday Hr00, Hr01, Hr02... Hr23  Min00, Min17,Min45…Min60 Min00_05, Min05_10 ... Min55_00 Q1, Q2, Q3, Q4 Hr00_Q1, Hr23_Q4 Day1 ... Day31 January, February, ... December Yr1997, Yr2004  ipv4_192_0_0_1, ipv4_192_0_0, ipv4_192_0, ipv4_192
Cfengine  之 control ( 类、方法、变量、表达式 ) 类的格式: action-type :  compound-class ::  declaration   逻辑操作符: `()' Parentheses override everything.  `!' The NOT operator binds tightest.  `. &' The AND operator binds more tightly than OR. `|' OR is the weakest operator. 如: class1|!class2::  、 !myhost::   变量(系统变量、自定义变量、列表) 系统变量: AllClasses 、 arch  、 binserver 、 domain  、 sysadm 、 timezone 等等 自定义变量: $(variable)  或  ${variable} 列表: listvar = ( one:two:three:four )
Cfengine  之 control ( 类、方法、变量、表达式 ) 系统变量表: AbortClasses   access   actionsequence   addclasses   addinstallable   AllowRedefinitionOf   AutoDefine   BinaryPaddingChar   ChecksumDatabase   BindToInterface(cfagent )   ChecksumPurge   ChecksumUpdates   childlibpath   copylinks   defaultcopytype   defaultpkgmgr   deletenonuserfiles   deletenonownerfiles   deletenonusermail   deletenonownermail   domain   dpkginstallcommand   repchar  repository  RPMcommand  rpminstallcommand   schedule   secureinput   sensiblecount   sensiblesize   showactions   singlecopy   site   SkipIdentify   Smtpserver   SplayTime   split   spooldirectories   suninstallcommand   suspiciousnames   sysadm   Syslog   SyslogFacility  timezone  TimeOut  Verbose  Warnings  warnnonuserfiles  warnnonownerfiles  warnnonusermail  warnnonownermail dryrun   editbinaryfilesize   editfilesize   emptyresolvconf   exclamation   excludecopy   excludelinks   ExpireAfter   FullEncryption   homepattern   HostnameKeys   IfElapsed   Inform   interfacename   lastseenexpireafter   fileextension   lastseen   linkcopies   LogDirectory   LogTidyHomeFiles   moduledirectory   mountpattern   netmask   nonalphanumfiles   nfstype   PortageInstallCommand
Cfengine  之 editfiles 格式: editfiles:  class:: { file-to-be-edited  action “quoted-string..."  }  例子: editfiles: linux:: { /etc/netmasks IncrementPointer "-1"  InsertLine "$(myservice)"  DeleteLinesContaining "255.255.254.0" AppendIfNoSuchLine “192.168  255.255.255.0" }
Cfengine  之 editfiles 常用方法: AutoCreate IncrementPointer "-1“ InsertLine string AppendIfNoSuchLine string 详细方法见 Cfengine 之 editfile 域方法 .doc
Cfengine 常用命令 cfservd  -v 启动 cfservd 服务 ( 前台 ) cfagent -v  如果不需要真正执行 , 可以加上 -n 参数 cfexecd -F  执行 Cfagent( 后台 ) cfrun -v  服务器端批量请求客户端代理,对单台服务器的请求 cfrun –v 192.168.100.5
Cfengine 问题总结 1 、 安装之前检查服务器时间是否正确。 2 、 Host authentication failed. Did you forget the domain name or IP/DNS address registration (for ipv4 or ipv6)?cfrun:tianyacaathe.: Couldn't recv (1) 在服务器端运行 cfrun -v IP 出现以上信息:检查客户端 cfservd.conf 文  件 AllowMultipleConnectionsFrom 的参数 ; (2) 在客户端运行 cfagent -v 出现以上信息,检查服务器端 cfservd.conf 文件 admit: 域的参数 ; 3 、 nothing to cfagent do…. 请隔 10 秒钟后再运行即可。
谢谢大家! Q&A http://blog.liuts.com

More Related Content

PPTX
Nae client(using Node.js to create shell cmd)
PDF
makefile20141121
PPTX
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
PPT
PPTX
5, system admin
PDF
九州通 Tsm重新配置文档(2008 11 10)
PPTX
使用Rpm&yum进行基础软件管理
PPTX
Memcached内存分析、调优、集群
Nae client(using Node.js to create shell cmd)
makefile20141121
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
5, system admin
九州通 Tsm重新配置文档(2008 11 10)
使用Rpm&yum进行基础软件管理
Memcached内存分析、调优、集群

What's hot (17)

DOC
Mysql mmm安装指南(翻译)
PDF
Intro to svn
XLS
Puppet安装总结
PDF
自由軟體鑄造場_20111023_Subversion版本控制系統之操作_曾義峰(ant)
PPT
0118 Windows Server 2008 的伺服器核心 (Server Core)
PDF
开源Pass平台flynn功能简介
PDF
Cent os 安装 subversion
PDF
Ruby on Rails 開發環境建置 for Mac
PDF
Ruby on Rails 開發環境建置 for Ubuntu
PPT
Cassandra运维之道(office2003)
PPT
Effective linux.2.(tools)
PDF
Linux chapt3
PDF
前端工程師一定要知道的 Docker 虛擬化容器技巧
PDF
Openshift by mtchang
PDF
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
PPTX
1, shell intro
DOC
Centos下安装apache + subversion
Mysql mmm安装指南(翻译)
Intro to svn
Puppet安装总结
自由軟體鑄造場_20111023_Subversion版本控制系統之操作_曾義峰(ant)
0118 Windows Server 2008 的伺服器核心 (Server Core)
开源Pass平台flynn功能简介
Cent os 安装 subversion
Ruby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for Ubuntu
Cassandra运维之道(office2003)
Effective linux.2.(tools)
Linux chapt3
前端工程師一定要知道的 Docker 虛擬化容器技巧
Openshift by mtchang
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
1, shell intro
Centos下安装apache + subversion
Ad

Cfengine培训文档 刘天斯

  • 1. Cfengine V2 主讲人:刘天斯
  • 2. 什么是 Cfengine? Cfengine ( 配置引擎 ) 是一种 UNIX 分布式系统管理实用程序 ,其目的是使简单的管理的任务自动化,使困难的任务变得较容易。它的目标是使系统任何状态收敛到一种理想状态。它适用于所有基于 UNIX 或类 UNIX 的操作系统,并且它可以通过 UNIX 兼容的环境 / 库 Cygwin 在较新版本的 Windows 操作系统中运行。
  • 3. Cfengine 可以做什么 ? ♦ 完成后期安装任务,例如配置网络界面信息。 ♦ 编辑系统配置文件以及其它文件。 ♦ 建立信号连接。 ♦ 检验、更正文件许可及所有权。 ♦ 删除无用文件。 ♦ 压缩被选文件。 ♦ 在网络中分发文件。 ♦ 自动挂载 NFS 文件系统。 ♦ 检查重要文件和文件系统是否存在及其完整性。 ♦ 执行命令及脚本。 ♦ 应用安全相关的补丁以及相似系统的修正。 ♦ 管理系统服务器进程。
  • 4. Cfengine 安装 mkdir -p /home/setup cd /home/setup wget http://192.168.100.247/cfengine/cfengine-2.2.5.tar.gz tar -zxvf cfengine-2.2.5.tar.gz && cd cfengine-2.2.5 ./configure make && make install /usr/local/sbin/cfagent -v /usr/local/sbin/cfkey /usr/local/sbin/cfexecd /usr/local/sbin/cfservd cp /usr/local/sbin/cfagent /var/cfengine/bin cp /usr/local/sbin/cfenvd /var/cfengine/bin cp /usr/local/sbin/cfexecd /var/cfengine/bin cp /usr/local/sbin/cfservd /var/cfengine/bin mkdir -p /var/cfengine/masterfile/inputs echo "/var/cfengine/bin/cfservd" >> /etc/rc.local echo "/var/cfengine/bin/cfenvd -H" >> /etc/rc.local echo "iptables -A INPUT -s 192.168.0.0/16 -p tcp --dport 5308 -j ACCEPT" >> /etc/firewall.sh /var/cfengine/bin/cfagent -v
  • 5. Cfengine 的组成部分 ♦ Cfagent : 解释策略的承诺并且以收敛的方式执行它们。代理可使用由统计监测引擎 Cfenvd 产生的数据,并且它能从运行于本地或远程主机上的 Cfenvd 中获取数据。 ♦ Cfexecd : 执行 Cfagent ,并且记录它的输出(可选择通过电子邮件寄出摘要)。它可 以在一个后台程序( standalone )的模式下运行,或者可以通过 cron 在一个类似于 Unix 的系统上运行。 ♦ Cfservd : 监控 Cfengine 的端口:提供文件数据,并在接收一个来自 cfrun 的连接的 基础上启动 Cfagent 。请注意,没有数据可以通过这个后台程序。 ♦ Cfrun : 联接远程主机,并要求他们运行 cfagent 。 ♦ Cfenvd : 收集在每台主机上使用资源的统计数据,用于异常状况的检测。信息以 cfengine 类的形式被代理获得,因此代理可以及时地对异常的动态状况进行检查并 作出反应。 ♦ Cfkey : 在主机生成“公有 - 私有”密钥对。一般作为 Cfengine 软件安装过程中的一 个步骤,你只需运行一次该程序。 ♦ Cfshow : 一旦你对它的内部存储感兴趣, cfshow 便将 cfagent 的数据库内容以 ASCII 的格式导入。 ♦ Cfenvgraph : 将 Cfenvd 的数据库内容导入为一种可用于图标格式显示一台主机在 其环境中的一般行为。
  • 6. Cfengine 组成部分之间的联系 1 )服务器上运行 cfrun,cfrun 会根据 cfrun.hosts 中的主机列表来连接到某个客户机的 cfservd 程序 2 )客户机上 cfservd 调用本机的 cfagent 程序 3 )客户机上 cfagent 程序执行 update.conf, 连接到中央机的 cfservd 复制下载策略文件 cafagent.conf 4 )客户机下载成功后执行最新版本的策略文件 , 不成功就执行旧版本的 .
  • 7. Cfengine 操作符 groups( 组合 ) control( 控制 ) homeservers( 主服务器 ) binservers( 执行文件服务器 ) mailserver( 邮件服务器 ) mountables( 挂载表 ) import( 导入 ) broadcast( 广播 ) resolve( 解析 ) defaultroute( 默认路由 ) directories( 目录 ) miscmounts( 杂项挂载 ) files( 文件 ) ignore( 忽略 ) tidy( 整理 ) required( 必需 ) links( 链接 ) disable( 禁用 ) shellcommands(shell 命令 ) editfiles( 编辑文件 ) processes( 过程 )
  • 8. Cfengine 策略文件 cfservd.conf control: domain = ( google.cn ) #add by liuts cfrunCommand = ( "/usr/local/sbin/cfagent" ) DenyBadClocks = ( false ) #add by liuts MaxConnections = ( 1000 ) AllowConnectionsFrom = ( 192.168.0.0/16 ) # AllowMultipleConnectionsFrom = ( 192.168.0 ) TrustKeysFrom = ( 192.168.0.0/16 ) AllowUsers = ( root ) MultipleConnections = ( true ) ######################################################### admit: # or grant: #add by liuts /var/cfengine/masterfile/inputs 192.168.0.0/16 /usr/local/sbin 192.168.0.0/16 /var/cfengine 192.168.0.0/16 /bin 192.168.0.0/16 /etc 192.168.0.0/16
  • 9. Cfengine 策略文件 update.conf # update.conf control: actionsequence = ( copy processes tidy ) domain = ( google.cn ) #policyhost = ( my_policy_host ) policyhost = ( cfengine.server.com ) master_cfinput = ( /var/cfengine/masterfile/inputs ) workdir = ( /var/cfengine ) copy: $(master_cfinput) dest=$(workdir)/inputs r=inf mode=700 type=binary server=$(policyhost) trustkey=true processes: "cfservd" restart /usr/local/sbin/cfservd "cfenvd" restart "/usr/local/sbin/cfenvd -H" tidy: $(workdir)/outputs pattern=* age=7 # End
  • 10. Cfengine 策略文件 cfagent.conf ( 一 ) control: access = ( root ) actionsequence = ( resolve copy files editfiles shellcommands ) domain = ( goolge.cn ) timezone = ( CST ) smtpserver = ( smtp.gmail.com ) # used by cfexecd sysadm = ( liutiansi@gmail.com ) # where to mail output EmptyResolvConf = ( true ) # listing = ( ExecResult("/bin/date -s 2008-04-30") ) ###################################################################### resolve: 8.8.8.8 ###################################################################### copy: /etc/passwd dest=/etc/passwd server=cfengine.server.com trustkey=true /etc/shadow dest=/etc/shadow server=cfengine.server.com trustkey=true ######################################################################
  • 11. Cfengine 策略文件 cfagent.conf ( 二 ) files: /etc/passwd mode=644 owner=root action=fixall checksum=md5 /etc/shadow mode=600 owner=root action=fixall ###################################################################### editfiles: { /home/config.txt AutoCreate AppendIfNoSuchLine "welcome to tianya.cn" } ###################################################################### shellcommands: "/bin/echo 'welcomesystem' > /var/cfengine/inputs/info.log" "/bin/echo $(listing) $(listing1)" ###################################################################### processes: "inetd" signal=hup "irc" signal=kill
  • 12. Cfengine 策略文件 (cfrun.hosts) # # This is the host list for cfrun # # Only these hosts will be contacted by remote connection # access=root 192.168.100.51 192.168.100.52 192.168.100.53 192.168.100.54 192.168.100.55 192.168.100.60 192.168.100.67 192.168.100.109 192.168.100.110 192.168.100.111 192.168.100.112 192.168.100.113 192.168.100.114
  • 13. Cfengine 之 control ( 类、方法、变量、表达式 ) Hard class: ultrix, sun4, sun3, hpux, hpux10, aix, solaris, osf, irix4, irix, irix64 sco, freebsd, netbsd, openbsd, bsd4_3, newsos, solarisx86, aos,nextstep, bsdos, linux, debian, cray,unix_sv, GnU, NT Time class : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday Hr00, Hr01, Hr02... Hr23 Min00, Min17,Min45…Min60 Min00_05, Min05_10 ... Min55_00 Q1, Q2, Q3, Q4 Hr00_Q1, Hr23_Q4 Day1 ... Day31 January, February, ... December Yr1997, Yr2004 ipv4_192_0_0_1, ipv4_192_0_0, ipv4_192_0, ipv4_192
  • 14. Cfengine 之 control ( 类、方法、变量、表达式 ) 类的格式: action-type : compound-class :: declaration 逻辑操作符: `()' Parentheses override everything. `!' The NOT operator binds tightest. `. &' The AND operator binds more tightly than OR. `|' OR is the weakest operator. 如: class1|!class2:: 、 !myhost:: 变量(系统变量、自定义变量、列表) 系统变量: AllClasses 、 arch 、 binserver 、 domain 、 sysadm 、 timezone 等等 自定义变量: $(variable) 或 ${variable} 列表: listvar = ( one:two:three:four )
  • 15. Cfengine 之 control ( 类、方法、变量、表达式 ) 系统变量表: AbortClasses access actionsequence addclasses addinstallable AllowRedefinitionOf AutoDefine BinaryPaddingChar ChecksumDatabase BindToInterface(cfagent ) ChecksumPurge ChecksumUpdates childlibpath copylinks defaultcopytype defaultpkgmgr deletenonuserfiles deletenonownerfiles deletenonusermail deletenonownermail domain dpkginstallcommand repchar repository RPMcommand rpminstallcommand schedule secureinput sensiblecount sensiblesize showactions singlecopy site SkipIdentify Smtpserver SplayTime split spooldirectories suninstallcommand suspiciousnames sysadm Syslog SyslogFacility timezone TimeOut Verbose Warnings warnnonuserfiles warnnonownerfiles warnnonusermail warnnonownermail dryrun editbinaryfilesize editfilesize emptyresolvconf exclamation excludecopy excludelinks ExpireAfter FullEncryption homepattern HostnameKeys IfElapsed Inform interfacename lastseenexpireafter fileextension lastseen linkcopies LogDirectory LogTidyHomeFiles moduledirectory mountpattern netmask nonalphanumfiles nfstype PortageInstallCommand
  • 16. Cfengine 之 editfiles 格式: editfiles: class:: { file-to-be-edited action “quoted-string..." } 例子: editfiles: linux:: { /etc/netmasks IncrementPointer "-1" InsertLine "$(myservice)" DeleteLinesContaining "255.255.254.0" AppendIfNoSuchLine “192.168 255.255.255.0" }
  • 17. Cfengine 之 editfiles 常用方法: AutoCreate IncrementPointer "-1“ InsertLine string AppendIfNoSuchLine string 详细方法见 Cfengine 之 editfile 域方法 .doc
  • 18. Cfengine 常用命令 cfservd -v 启动 cfservd 服务 ( 前台 ) cfagent -v 如果不需要真正执行 , 可以加上 -n 参数 cfexecd -F 执行 Cfagent( 后台 ) cfrun -v 服务器端批量请求客户端代理,对单台服务器的请求 cfrun –v 192.168.100.5
  • 19. Cfengine 问题总结 1 、 安装之前检查服务器时间是否正确。 2 、 Host authentication failed. Did you forget the domain name or IP/DNS address registration (for ipv4 or ipv6)?cfrun:tianyacaathe.: Couldn't recv (1) 在服务器端运行 cfrun -v IP 出现以上信息:检查客户端 cfservd.conf 文 件 AllowMultipleConnectionsFrom 的参数 ; (2) 在客户端运行 cfagent -v 出现以上信息,检查服务器端 cfservd.conf 文件 admit: 域的参数 ; 3 、 nothing to cfagent do…. 请隔 10 秒钟后再运行即可。