User story #9057
closedAllow the use of node properties info in Directive parameters
Description
This is the remaining part of #6733, where we allow user to use node propertise in directives parameters. These node properties will be replaced by their value at generation time, so that they can be used (for example) as input for JS transformation.
The chosen format for ncf technique, as documented in http://www.rudder-project.org/doc-3.1/_using_properties.html, is the following:
${node.properties[datacenter]}
And you can descend into a json structure:
${node.properties[datacenter][europe][france]}
We must use the same in directive, at least for the data access.
Question: do we want to let the possiblity to have in a directive parameter
${node.properties[datacenter]}
to tell "I really want that to be changed at runtime, and not at generation time", and so for node properties that have to be change at generation time, use something like
${rudder.node.properties[datacenter]}
?
Open question 2: what to do if the key sequence does not exists ? (i.e, in the example, [datacenter] is not defined) ? The possible option are:
1/ fails the generation, "missing property blabla in nodes node1, node2, node3
2/ use a default value (empty string, the string "null", etc)
3/ actually returns ${node.properties[datacenter]
The sanest (less surprise, fails early) is clearly 1/, but it certainly can lead to unpleasant case where one node block the whole generation (until rudder is able to generate policies node by node).
2/ and 3/ are variation of the same poison, and WILL lead to unexpected behaviour and surprises (anybody looking for "rm -rf ${prop1}/{prop2}, where neither are defined and so replaced by "" ?). On the other hand, it is much less frustrating when you are in an urge to deploy something and rudder keeps telling that their is 200 nodes with incorrect properties. And for the ncf/technique part of the feature, it's the behaviour (3/ actually, I believe).
Updated by François ARMAND over 8 years ago
(backporting comments from #6733)
Francois:
Personnaly, I don't think it is a good idea to have to almost identical, because it's extremelly surprising (vastly different behaviour for almost the same thing). And a work around can certainly be used by calling the full CFEngine variable name (i.e:
${properties.property__var_rudder_cfengine_community_inputs_properties_d_properties_json[properties][datacenter]} - this one won't be changed at generation time).
Benoit:
I think replace a perfectly regular cfengine variable is also surprising for the user knowing cfengine and knowing how to use it.
A different argument would be that we want to be as much as possible independent of the underlying agent, so things from the user in the interface must be as much as possible processed before being sent to the agent.
Updated by François ARMAND over 8 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from François ARMAND to Vincent MEMBRÉ
- Pull Request set to https://github.com/Normation/rudder/pull/1194
Updated by François ARMAND about 8 years ago
- Assignee changed from Vincent MEMBRÉ to Nicolas CHARLES
Updated by François ARMAND about 8 years ago
- Assignee changed from Nicolas CHARLES to Vincent MEMBRÉ
Updated by François ARMAND about 8 years ago
- Assignee changed from Vincent MEMBRÉ to Nicolas CHARLES
Updated by François ARMAND about 8 years ago
- Assignee changed from Nicolas CHARLES to Vincent MEMBRÉ
Updated by François ARMAND about 8 years ago
- Assignee changed from Vincent MEMBRÉ to Nicolas CHARLES
Updated by François ARMAND about 8 years ago
- Assignee changed from Nicolas CHARLES to Vincent MEMBRÉ
Updated by François ARMAND about 8 years ago
- Assignee changed from Vincent MEMBRÉ to Nicolas CHARLES
Updated by François ARMAND about 8 years ago
- Status changed from Pending technical review to Pending release
- % Done changed from 0 to 100
Applied in changeset rudder|3f2bce3918abbcc0f0d7ea9cc1171cacd43ad721.
Updated by François ARMAND about 8 years ago
- Related to User story #9158: Normalize ${rudder.parameter} syntaxe between ncf and directive added
Updated by Vincent MEMBRÉ about 8 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 3.1.15/14 and 3.2.8/7 which were released today.
- 3.1: Announce Changelog
- 3.2: Announce Changelog
- Download: https://www.rudder-project.org/site/get-rudder/downloads/