Type: Knowledge acquisition
Affects Version/s: None
Fix Version/s: None
Support for multiple augments has been merged (#
CFE-2084). The current implementation behavior surprised me and I would like to gain some consensus on the desired behavior.
Currently the agent processes a supplementary augments file as soon as it is seen during parsing. This results in difference of behavior based on the position of the augments key in def.json.
That means that this def.json:
That loads this supplementary augments (/$(sys.inputdir)/$(sys.flavor).json=/=/var/cfengine/inputs/centos_6.json):
Will produce this report for the value of def.myvar:
And this def.json with the augments key specified last:
Will produce this output for def.my_var:
So when a variable is defined in the main augments, and re-defined in a supplementary augments, the position of the augments key itself dictates who will win. If the augments key is defined BEFORE vars then the main def.json vars will function like a global override (until it gets to policy). And if the augments key is defined AFTER vars then the variables defined in the supplementary augments function as overrides to the global defaults defined in def.json.
I can see this being potentially useful, but I can also see it being confusing.
If you have supplementary vars you want to be defined only if not specified globally then you put the augments key at the top.
And you will get output like this:
Move augments after vars again and get output like this:
So my question is, do you like the current behavior OR should the augments key ALWAYS be processed LAST, so that it only functions as an overlay, and cannot function as a global enforcement allowing supplementary files to define additional variables.