On Fri, 27 Feb 2015 16:46:37 +0000 (UTC) Riccardo Murri <
riccard...@uzh.ch> wrote:
RM> has anyone tried to use the `variablesmatching()` function?
RM> I am experimenting with it to use external templating engines [1],
RM> but have run into troubles (see [2], [3]).
RM> Are there any undocumented catches for using `variablesmatching()`?
RM> For instance, it seems that namespace info is mangled and one must use
RM> `#` instead of the colon character to separate namespace from the
RM> variable name ...
RM> [1]:
https://gist.github.com/riccardomurri/bb3bd26406724f4193e6
If I understand your example correctly, you're actually looking for the
datastate() function, new in 3.6:
https://docs.cfengine.com/docs/master/reference-functions-datastate.html
Once you have the data state captured, you can extract pieces of it[1] or
serialize the whole thing. Unfortunately until 3.7 you won't have the
new Mustache escape sequence to serialize a large data container (see
https://github.com/cfengine/core/pull/2031) so you'll be limited to 4K
on the serialized version of the data state. But do you *really* need
all of it? My guess is no.
If you must have absolutely all the data, you can generate some kind of
K=V format file in Mustache but it's not trivial.
Ted
[1] extract everything under key1 to a new container:
"subcontainer" data => mergedata("bigcontainer[key1]");