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

Need to allow meta tags for variables and classes in augments / cmdb

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Higher
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.18.0
    • Component/s: None
    • Labels:
      None

      Description

      • We introduce a new key to the augments format variables (this is what Mission Portal API will target).
      • variables requires a more complex structure than vars so that it can support targeting setting meta data (ENT-7038).

      Example data structure:

      $(sys.workdir)/data/host_specific.json
      {
          "variables": {
              "TestVar": {
                  "value": "I hold the value of cmdb:variables.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:variables.TestVar"
                  ]
              },
              "TestBundle.TestVar": {
                  "value": "I hold the value of cmdb:TestBundle.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:TestBundle.TestVar"
                  ]
              },
              "TestNamespace:TestBundle.TestVar": {
                  "value": "I hold the value of TestNamespace:TestBundle.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB TestNamespace:TestBundle.TestVar"
                  ]
              },
              "TestVarList": {
                  "value": [ "I", "hold", "the", "value", "of", "cmdb:variables.TestVarList"],
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:variables.TestVarList"
                  ]
              },
              "TestBundle.TestVarList": {
                  "value": [ "I", "hold", "the", "value", "of", "cmdb:TestBundle.TestVarList"],
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:TestBundle.TestVarList"
                  ]
              },
              "TestNamespace:TestBundle.TestVarList": {
                  "value": [ "I", "hold", "the", "value", "of", "cmdb:TestBundle.TestNamespace:TestBundle.TestVarList"],
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB TestNamespace:TestBundle.TestVarList"
                  ]
              },
              "TestVarDataContainer": {
                  "value": { "I": "hold", "the": "value", "of": "cmdb:variables.TestVarDataContainer"},
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:variables.TestVarDataContainer"
                  ]
              },
              "TestBundle.TestVarDataContainer": {
                  "value": { "I": "hold", "the": "value", "of": "cmdb:TestBundle.TestVarDataContainer"},
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:TestBundle.TestVarDataContainer"
                  ]
              },
              "TestNamespace:TestBundle.TestVarDataContainer": {
                  "value": { "I": "hold", "the": "value", "of": "TestNamespace:TestBundle.TestVarDataContainer"},
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB TestNamespace:TestBundle.TestVarDataContainer"
                  ]
              },
              "TestVarInt": {
                  "value": -678,
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:variables.TestVarInt"
                  ]
              },
              "TestBundle.TestVarInt": {
                  "value": 1,
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:TestBundle.TestVarInt"
                  ]
              },
              "TestNamespace:TestBundle.TestVarInt": {
                  "value": 999999999,
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB TestNamespace:TestBundle.TestVarInt"
                  ]
              }
          }
          "classes":{
              "MyCurrentImplementation" : [ "list ", "of"],
              "MyNEWImplementation" : {
                  "class_expressions": [ "thing::", "of.things::" ],
                  "regular_expressions": [ "^myClass", "redhat_.*" ],
                  "tags": [
                      "inventory",
                      "attribute_name=Inventory dis shit"
                  ]
              }
      }
      

      A small example

      $(sys.workdir)/data/host_specific.json
      {
          "variables": {
              "TestVar": {
                  "value": "I hold the value of cmdb:variables.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:variables.TestVar"
                  ]
              },
              "TestBundle.TestVar": {
                  "value": "I hold the value of cmdb:TestBundle.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB cmdb:TestBundle.TestVar"
                  ]
              },
              "TestNamespace:TestBundle.TestVar": {
                  "value": "I hold the value of TestNamespace:TestBundle.TestVar",
                  "tags": [
                      "inventory",
                      "attribute_name=CMDB TestNamespace:TestBundle.TestVar"
                  ]
              }
          }
      }
      
      bundle agent __main__
      {
          reports:
           "CFEngine $(sys.cf_version)"; 
      
            "$(sys.workdir)/data/host_specific.json"
             printfile => cat( $(this.promiser) );
      
           "cmdb:varaibles.TestVar = $(cmdb:variables.TestVar)";
           "cmdb:TestBundle.TestVar = $(cmdb:TestBundle.TestVar)";
      }    
      
      R: CFEngine 3.18.0a.b248be4d0
      R: /home/nickanderson/.cfagent/data/host_specific.json
      R: {
      R:   "variables": {
      R:         "TestVar": {
      R:             "value": "I hold the value of cmdb:variables.TestVar",
      R:             "tags": [
      R:                 "inventory",
      R:                 "attribute_name=CMDB cmdb:variables.TestVar"
      R:             ]
      R:         },
      R:         "TestBundle.TestVar": {
      R:             "value": "I hold the value of cmdb:TestBundle.TestVar",
      R:             "tags": [
      R:                 "inventory",
      R:                 "attribute_name=CMDB cmdb:TestBundle.TestVar"
      R:             ]
      R:         },
      R:         "TestNamespace:TestBundle.TestVar": {
      R:             "value": "I hold the value of TestNamespace:TestBundle.TestVar",
      R:             "tags": [
      R:                 "inventory",
      R:                 "attribute_name=CMDB TestNamespace:TestBundle.TestVar"
      R:             ]
      R:         }
      R:     }
      R: }
      R: cmdb:varaibles.TestVar = I hold the value of cmdb:variables.TestVar
      R: cmdb:TestBundle.TestVar = I hold the value of cmdb:TestBundle.TestVar
      R: TestNamespace:TestBundle.TestVar = I hold the value of TestNamespace:TestBundle.TestVar
      

      The variables should be viewable with cf-promises --show-vars like this:

      exec 2>&1
      cf-promises --show-vars | head -n 1
      cf-promises --show-vars | grep cmdb
      :
      
      cmdb:variables.TestVar                   I hold the value of cmdb:variables.TestVar source=cmdb,inventory,attribute_name=CMDB cmdb:variables.TestVar                            
      cmdb:TestBundle.TestVar                  I hold the value of cmdb:variables.TestVar source=cmdb,inventory,attribute_name=CMDB cmdb:TestBundle.TestVar
      TestNamespace:TestBundle.TestVar         I hold the value of TestNamespace:variables.TestVar source=TestNamespace,inventory,attribute_name=CMDB TestNamespace:TestBundle.TestVar

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vpodzime Vratislav Podzimek
              Reporter:
              olehermanse Ole Herman Schumacher Elgesem
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: