Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6054

lookup lacks deep hash interprolation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Duplicate
    • Affects Version/s: PUP 4.3.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:
    • Team:
      Puppet Developer Experience

      Description

      Given data like this, hiera would replace the facts, lookup does not:

      classifier::rules:
        RedHat VMs:
          match: all
          rules:
            - fact: "%{facts.os.family}"
              operator: ==
              value: RedHat
            - fact: "%{facts.is_virtual}"
              operator: ==
              value: true
          classes:
            - centos::vm
      

      With environment data not enabled and classic hiera on I get:

      % puppet lookup --environmentpath environments --hiera_config hiera.yaml classifier::rules --explain
      Using merge options from "lookup_options" hash
      Merge strategy deep
        Data Binding "hiera"
          Found key: "classifier::rules" value: {
            "RedHat VMs" => {
              "match" => "all",
              "rules" => [
                {
                  "fact" => "RedHat",
                  "operator" => "==",
                  "value" => "RedHat"
                },
                {
                  "fact" => "is_virtual",
                  "operator" => "==",
                  "value" => true
                }
              ],
              "classes" => [
                "centos::vm",
                "some::other"
              ]
            }
          }
      

      Disable that and enable environment data:

      Using merge options from "lookup_options" hash
      Merge strategy deep
        Data Binding "hiera"
          No such key: "classifier::rules"
        Data Provider "Hiera Data Provider, version 4"
          ConfigurationPath "/home/rip/temp/classifier/environments/production/hiera.yaml"
          Merge strategy deep
            Data Provider "%{trusted.certname}"
              Path "/home/rip/temp/classifier/environments/production/hieradata/dev2.devco.net.yaml"
                Original path: "%{trusted.certname}"
                Path not found
            Data Provider "common"
              Path "/home/rip/temp/classifier/environments/production/hieradata/common.yaml"
                Original path: "common"
                Found key: "classifier::rules" value: {
                  "RedHat VMs" => {
                    "match" => "all",
                    "rules" => [
                      {
                        "fact" => "%{facts.os.family}",
                        "operator" => "==",
                        "value" => "RedHat"
                      },
                      {
                        "fact" => "is_virtual",
                        "operator" => "==",
                        "value" => true
                      }
                    ],
                    "classes" => [
                      "centos::vm"
                    ]
                  }
                }
            Merged result: {
              "RedHat VMs" => {
                "match" => "all",
                "rules" => [
                  {
                    "fact" => "%{facts.os.family}",
                    "operator" => "==",
                    "value" => "RedHat"
                  },
                  {
                    "fact" => "is_virtual",
                    "operator" => "==",
                    "value" => true
                  }
                ],
                "classes" => [
                  "centos::vm"
                ]
              }
            }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ripienaar R.I.Pienaar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support