Implement "onchange" support

"onchange" specifies execution prerequisites. It is specified in the same way
as "require", it implies "require", but it specifies that object is executed
only if any of specified prerequisites has changed target's state. This means
that any of specified prerequisites has generated code to be executed, either
local or remote or both.

Object has generated code if it itself has generated code or if any of its
children object has generated code.

Resolve #843.
This commit is contained in:
Darko Poljak 2021-03-21 18:10:06 +01:00
commit 7f32e5855a
6 changed files with 172 additions and 45 deletions

View file

@ -154,6 +154,16 @@ You can find a more in depth description of the flow execution of manifests
in `cdist execution stages <cdist-stages.html>`_ and of how types work in `cdist type <cdist-type.html>`_.
Processing preconditions
------------------------
If you want to describe that something should be processed only if specified
objects changed target's state, i.e. specified objects generated either
"code-local" or "code-remote", or both, just setup the variable "onchange" to
contain processing preconditions. "onchange" is specified in the same way as
"require", and it implies "require". If processing preconditions are not
satisfied then it means that object's explorers are not run, manifest is not
run, and gencode scripts are not run. Object processing is skipped.
Create dependencies from execution order
-----------------------------------------
You can tell cdist to execute all types in the order in which they are created
@ -375,3 +385,13 @@ Dependencies defined by execution order work as following:
require="__some_type_somewhere/id __sample_type/1" __sample_type 2
require="__sample_type/2" __example_type 23
__not_in_order_type 42
This example makes use of processing preconditions:
.. code-block:: sh
__foo bar
__spam eggs
# execute __baz type only if any of __foo/bar, __spam/eggs has changed
# target's state, i.e. code-local or code-remote is generated (or both)
onchange='__foo/bar __spam/eggs' __baz

View file

@ -314,6 +314,9 @@ The following environment variables influence the behaviour of cdist:
require
Setup dependencies between objects (see \`cdist manifest <cdist-manifest.html>\`_).
onchange
Setup processing preconditions (implies dependencies) between objects (see `cdist manifest <cdist-manifest.html>`_).
__cdist_log_level
cdist log level value. One of: