Project

General

Profile

Actions

Architecture #11858

closed

Add common pre- and post- agent run action triggered by technique logic

Added by Benoît PECCATTE almost 7 years ago. Updated over 6 years ago.

Status:
Released
Priority:
N/A
Category:
Web - Config management
Target version:
Effort required:
Name check:
Fix check:
Regression:

Description

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 in the bundle sequence by mapping them to 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 be defined in the directive logic)


Subtasks 2 (0 open2 closed)

Architecture #12028: Missing simple quote on "Add common pre- and post- agent run action triggered by technique logic" testReleasedNicolas CHARLESActions
Architecture #12179: Pre-/Post-run hook format evolutionReleasedFrançois ARMANDActions

Related issues 2 (0 open2 closed)

Related to Rudder - User story #11851: Port techniques to multi-versionned formatReleasedActions
Related to Rudder - Architecture #11940: Warn if an "uniqueVariable" is found in a techniqueReleasedFrançois ARMANDActions
Actions

Also available in: Atom PDF