Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2741

DISCUSS is should supplementary augments always be processed LAST or should it be based on position of augments key

    XMLWordPrintable

    Details

    • Type: Knowledge acquisition
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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:

      {
        "augments": [
          "$(sys.inputdir)/$(sys.flavor).json"
        ],
      
        "vars":{
          "my_var": "defined in def.json"
        }
      }
      

      That loads this supplementary augments (/$(sys.inputdir)/$(sys.flavor).json=/=/var/cfengine/inputs/centos_6.json):

      {
        "vars": {
          "my_var": "Defined in centos_6.json"
        }
      }
      

      Will produce this report for the value of def.myvar:

      R: def.my_var == defined in def.json
      

      And this def.json with the augments key specified last:

      {
        "vars":{
          "my_var": "defined in def.json"
        },
      
        "augments": [
          "$(sys.inputdir)/$(sys.flavor).json"
        ]
      }
      

      Will produce this output for def.my_var:

      R: def.my_var == Defined in centos_6.json
      

      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:

      R: def.my_var == defined in def.json
      R: def.my_other_var == Defined ONLY in def.json
      R: def.centos_6_var == Defined ONLY in centos_6.json
      

      Move augments after vars again and get output like this:

      R: def.my_var == Defined in centos_6.json
      R: def.my_other_var == Defined ONLY in def.json
      R: def.centos_6_var == Defined ONLY in centos_6.json
      

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: