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

Hiera hash keys are being converted to strings recursively

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 4.9.0, PUP 4.9.1, PUP 4.9.2, PUP 4.9.3, PUP 4.9.4, PUP 4.10.0, PUP 4.10.1
    • PUP 4.10.2, PUP 5.0.0
    • None
    • Agent
    • 1
    • PDE 2017-05-31, Agent 2017-06-14
    • Needs Assessment
    • Bug Fix
    • A regression was found that from Puppet >= 4.9 hiera data containing Integer or Float keys ended up having those keys converted to String. The intention was to only filter out Ruby Symbol keys. Integer and Float keys in hashes now work as they should,
    • Automate
    • covered by unit tests, these need extension (see henrik's comment re hash digging)

    Description

      Puppet 4.9+ currently converts hiera hash elements into strings unconditiionally. YAML.load_file() will deserialize say an Integer to a ruby Fixnum, but the function symkeys_to_string converts every key to a string, regardless of whether it is a symbol.

      Here is a simple example:

      $ports = lookup("ports")
       
      $ports.each |$port, $options | {
      	$port_type = type(Integer.new($port), 'generalized')
      	notify { "${port} = ${port_type}":}
      }
      

      common.yaml:

      ports:
        80:
          test: test
        443:
          test: test
      

      And the output:

      Notice: 80 = String
      Notice: /Stage[main]/Main/Notify[80 = String]/message: defined 'message' as '80 = String'
      Notice: 443 = String
      Notice: /Stage[main]/Main/Notify[443 = String]/message: defined 'message' as '443 = String'
      Notice: Applied catalog in 0.02 seconds
      

      This is also a regression in functionality from Puppet <4.8. PR uploaded to https://github.com/puppetlabs/puppet/pull/5912

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              d.cochran Dylan Cochran
              Eric Delaney Eric Delaney
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support