Adding Modules to cfengine 3

Cfengine 3 is designed to be highly modular and uniform in syntax. To add a new functionality, you Plan a model based on promises What are the promises you want to make? What promise types will you need? file: newtype: What attributes (lvalues) will the promise body have? What datatypes will the attributes have? Then you start in src/mod_common.c
/*********************************************************/
/* THIS IS WHERE TO ATTACH SYNTAX MODULES                */
/*********************************************************/

/* Read in all parsable Bundle definitions */

struct SubTypeSyntax *CF_ALL_SUBTYPES[CF3_MODULES] =
   {
   CF_COMMON_SUBTYPES, /* Add modules after this */
   CF_FILES_SUBTYPES,  /* mod_files.c */
   CF_EXEC_SUBTYPES,   /* mod_exec.c */
   CF_PROCESS_SUBTYPES,/* mod_process.c */
   
   /* update CF3_MODULES in cf3.defs.h */
   };

Remember to increase the constant CF3_MODULES when you increase the size of this. Add a reference to the new module here. Take an existing module, e.g. mod_exec.c and copy it to your new module. Rename the parts consistently with the module name and edit this to add the required promises with attributes. Don't forget the preprocessor labels CF3_MOD_NEW You will have to add the mod_new.c file to Makefile.am Add a section to cf3.extern.h to declare the new variables, following the pattern there.
Mark Burgess
Last modified: Fri Jan 4 15:55:46 CET 2008