Could you try to use the CFEngine_include_snippet() macro to get this code from a .cf file in core/examples?