Project

General

Profile

Architecture #11858

Updated by François ARMAND over 6 years ago

We would like to have some cfengine code shared between more than one version of a technique. This is needed to be able to "merge" common action like restarting a service if its config file was updated, or execute a command to get a common information.  

 

 For example we would have 3 versions of technique A : 
 * A/v1/code.st 
 * A/v1/common.st 
 * A/v2/code.st 
 * A/v2/common.st 
 * A/v3/code.st 
 * A/v3/common.st 

 If both v1 and v2 are used, the generator would use    :  
 * A/v1/code.st 
 * A/v2/code.st 
 * A/v2/common.st 

 To generate the final content. 

 After some thought on it (see comments), the chosen solution is to add a notion of run-hooks implemented like that:  

 - in metadata.xml, we add an optionnal section in <AGENT> with the following parameters: pre or post hook, hook type (service restart, command, variable from command, package), parameters (a list of k/value), condition (a class expression) 
 - during generation, on a given node, we:  
   - accumulate pre (post) hooks which differ on type or parameters 
   - merge (i.e: accumulate reportid, "or" condition) hooks with same type / parameters 
 - we add the resulting pre (post) hooks We would need something in the bundle sequence by mapping them metadata.xml to indicate this shared code, and which versions are compatible, and if the corresponding method calls 

 Note: reports are for all directive registering for a hook. It makes no sense to have a report for only one directive (because in that case, it is not a common code, it's some code specific to one directive that should must be defined in run before of after the directive logic) 
 version specific code.

Back