From IT Mission Linux Tips, Hacks, Tutorials, Howtos - Itmission.org

Main: Example-CFEngine-policy-server-and-client


Task :

Create cftest1.cf under /var/cfengine/masterfiles/

[root@mail.zimbra.lab ~]# cd /var/cfengine/masterfiles/
[root@mail.zimbra.lab masterfiles]# ls
0010_Basic_Examples._Create_a_file.cf  cfengine_stdlib.cf  cf_promises_validated  failsafe.cf  promises.cf

!!!Create cftest1.cf

[root@mail.zimbra.lab masterfiles]# vi cftest1.cf

#====
 bundle agent test 
     {   
     files: 
       "/tmp/cf_test_file"   
           comment => "Promise that a plain file exists with stated permissions",
             perms => mog("644", "root", "sys"),
            create => "true";
     }
#===

Now Modify promises.cf and add the details for cftest.cf

root@mail.zimbra.lab masterfiles]# vi  /var/cfengine/masterfiles/promises.cf

###############################################################################
#
#   promises.cf - Basic Policy for Community
#
###############################################################################

body common control
{
 bundlesequence => { "main","test" };

 inputs => {
            "cfengine_stdlib.cf",
            "cftest.cf",
           };

 version => "Community Promises.cf 1.0.0";
}

Save the /var/cfengine/masterfiles/promises.cf file.

Return to cfhost and manually start the agent by running: ‘

/var/cfengine/bin/cf-agent -Kv 

The ‘-K’ switch will bypass any locks and the ‘-v’ switch will allow you to see the actual output. By default, cf-agent will only execute a policy at minimum once a minute. When we specify the -K flag on the command line at the 3rd execution, the -K instructs cf-agent to ignore this "one minute rule" .

Retrieved from http://www.itmission.org/Main/Example-CFEngine-policy-server-and-client
Page last modified on July 28, 2012, at 05:56 AM