主要功能
在多至上萬臺主機的系統中,集中定義配置,然后自動應用到所有主機。
自動進行哪些配置呢?主要有:
² 網口配置
² 修改各種配置文件
² 建立并保持符號鏈接
² 掛接(mount)NFS文件系統
² 檢查和保持文件的權限信息
² 檢查重要文件
² 幫助運行用戶腳本
² 進程管理
組件結構
cfagent從cfservd下載規則及需要的文件,然后通過規則配置本地系統,達到整個網絡的集中配置。
其規則定義有專門的結構。
Cfagent一般可以配作定時任務定期“被動”運行。Cfservd除用作“文件服務”外,還有個特殊功能,可以“主動”運行本機的cfagent,這是通過遠端的cfrun來激發的。
規則語言:
即一個節一個節的定義動作類型,動作類型是預定義好的,用戶不能添加。
節中可以用“類”來對特定的一組主機進行的操作,類以兩個冒號結尾。
action-type:
class1::
list of things to do...
class2::
list of things to do...
action-type:
groups, control, copy, homeservers, binservers, mailserver, mountables,
import, broadcast, resolve, defaultroute, directories, miscmounts,
files, ignore, tidy, required, links, disable, shellcommands, strategies
editfiles, processes
Control節中的actionsequence就表示全部動作的執行順序,之后的節就定義需要執行的動作。
如下面即表示,在SUN4的操作系統上創建/bin->/usr/bin的符號鏈接
# Comment...
control:
actionsequence = ( links )
links:
sun4::
/bin -> /usr/bin
# other links
osf::
# other links
舉例
從policyhost拷貝文件到本地:
copy:
$(master_cfinput) dest=$(workdir)/inputs
r=inf
mode=700
type=binary
exclude=*.lst
exclude=*~
exclude=#*
server=$(policyhost)
刪除多余的過期文件:
tidy:
#
# Cfexecd stores output in this directory.
# Make sure we don't build up files and choke on our own words!
#
$(workdir)/outputs pattern=* age=7
向文件.cshrc添加行:
{ home/.cshrc
AppendIfNoSuchLine "# Sys admin/cfengine: put next line here"
AppendIfNoSuchLine "setenv PRINTER newprinter"
}
鏈接: