CentOS 6 install & configure Cfengine

1、安装软件包

#yum install openssl openssl-devel db4 db4-devel flex pcre pcre-devel openldap tokyocabinet tokyocabinet-devel gcc  -y

2、下载source包

#wget https://cfengine.com/source-code/download?file=cfengine-3.5.1-3.tar.gz

#tar xvzf cfengine-3.5.1-3.tar.gz; cd cfengine-3.5.1-3

#./configure

#make && make install

3、/var/cfengine 默认工作目录

#cp -rp  cfengine-3.5.1-3/masterfiles/*.cf  /var/cfengine/masterfiles

#cp -rp cfengine-3.5.1-3/masterfiles/*.cf /var/cfengine/inputs

#cp -rp cfengine-3.5.1-3/masterfiles/controls /var/cfengine/inputs

#cp -rp cfengine-3.5.1-3/masterfiles/services /var/cfengine/inputs

#cp -rp cfengine-3.5.1-3/masterfiles/lib /var/cfengine/inputs

#cp -rp cfengine-3.5.1-3/masterfiles/libraries/cfengine_stdlib.cf /var/cfengine/inputs

4、测试配置是否成功

#/var/cfengine/bin/cf-promises -v

5、实例:创建一个新文件" /tmp/cftest " , 文件权限 774

# cat /var/cfengine/inputs/cftest.cf

body common control
{
# Define a bundle sequence
bundlesequence => { "checkperms" };
# Include cfengine_stdlib.cf
inputs => { "cfengine_stdlib.cf" };
version => "1.0.0";
}
bundle agent checkperms        
{
files:                   
"/tmp/cftest"
create => "true",                             
perms => m("744");
}

6、检测配置语法

#/var/cfengine/bin/cf-promise -f /var/cfengine/inputs/cftest.cf

#ls -l /tmp/cftest
ls: 无法访问/tmp/cftest: 没有那个文件或目录

7、运行

#/var/cfengine/bin/cf-agent -f /var/cfengine/inputs/cftest.cf

#ls -l /tmp/cftest

-rwxr--r-- 1 root root 0 7月  23 14:24 /tmp/cftest

注意:文件创建成功和权限是正确的,这只是一个简单的实例,待后续讲解。。。

你可能感兴趣的:(source,target,title,blank,软件包)