Cfengine configuration directory

Built in functions for classes and variables

Relevant classes: any

Some internal functions may be used to set classes and variables:

Variable assignment built-ins

  • ExecResult(command) Executes the named shell command and inserts the output into the variable.
  • RandomInt(a,b) Generate a random integer between a and b.
Examples:

  control:

   # old method

   listing = ( "exec /bin/ls -l" )

   # new method

   listing = ( ExecResult(/bin/ls -l) )

   random_hour  = ( RandomInt(0,23) )

Class assignment builtins

  • IsnewerThan(f1,f2) True if file 1 is modified more recently than file 2. (mtime)
  • AccessedBefore(f1,f2) True if file 1 had its last access earlier than file 2 (atime)
  • ChangedBefore(f1,f2) True if file 1's attributes were changed in any way before file 2's (ctime).
  • Fileexists(f) True if the named file object exists.
  • IsDir(f) True if the named file object is a directory.
  • IsLink(f) True if the named file object is a symbolic link.
  • IsPlain(f) True if the named file object is a plain file.
  • ReturnsZero(comm) True if the named shell command returns with exit code zero (okay).


classes:

 access_to_dir = ( ReturnsZero(/bin/cd /mydir) )
 compare       = ( ChangedBefore(/etc/passwd_master,/etc/passwd) )
 isplain       = ( IsPlain(/tmp/import) )


Back to documentation