Uploaded image for project: 'Hiera'
  1. Hiera
  2. HI-220

Deprecate interpolation via function in hiera.yaml

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: HI 1.3.0
    • Fix Version/s: HI 3.1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      CentOS 6.5
      Hiera 1.3.1 from PL yum repos

    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2015-12-16, Language 2015-12-30
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Calling {{hiera}} interpolation method from within a hiera.yaml caused infinite reqursion. This was fixed by making it an error to se {{hiera}} method in interpolation in hiera.yaml. Also, the use of other interpolation methods in hiera.yaml will now yield a deprecation warning as those will not be allowed in hiera 4.0.
      Show
      Calling {{hiera}} interpolation method from within a hiera.yaml caused infinite reqursion. This was fixed by making it an error to se {{hiera}} method in interpolation in hiera.yaml. Also, the use of other interpolation methods in hiera.yaml will now yield a deprecation warning as those will not be allowed in hiera 4.0.

      Description

      Given the following hiera.yaml file where an interpolation function is used to define the hierarchy:

      ---
      :backends:
        - yaml
      :logger: console
      :hierarchy:
        - "roles/%{hiera('role')}"
        - common
       
      :yaml:
         :datadir: /etc/puppet/environments/%{environment}/extdata
      

      This will result in infinite recursion on any lookup:

      # hiera foo -d
      DEBUG: Tue Feb 25 19:57:34 -0800 2014: Hiera YAML backend starting
      DEBUG: Tue Feb 25 19:57:34 -0800 2014: Looking up foo in YAML backend
      DEBUG: Tue Feb 25 19:57:34 -0800 2014: Looking up role in YAML backend
       
      ... repeats for a bit ...
       
      DEBUG: Tue Feb 25 19:57:34 -0800 2014: Looking up role in YAML backend
      DEBUG: Tue Feb 25 19:57:39 -0800 2014: Looking up role in YAML backend
      DEBUG: Tue Feb 25 19:57:39 -0800 2014: Looking up role in YAML backend
      /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:172:in `lookup': stack level too deep (SystemStackError)
      	from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:171:in `each'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:171:in `lookup'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/interpolate.rb:43:in `hiera_interpolate'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/interpolate.rb:13:in `send'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/interpolate.rb:13:in `interpolate'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/recursive_guard.rb:16:in `check'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/interpolate.rb:11:in `interpolate'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:93:in `parse_string'
      	 ... 1747 levels...
      	from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:171:in `each'
      	from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:171:in `lookup'
      	from /usr/lib/ruby/site_ruby/1.8/hiera.rb:60:in `lookup'
      	from /usr/bin/hiera:221
      

      The docs mention that using hiera():

      ...generally nonsensical and not useful in Hiera’s settings

      However, there are some semi-useful use cases. For example, the following hierarchy is functional:

      :hierarchy:
        - "%{::certname}" # <-- "role" is defined here. Always.
        - "roles/%{hiera('role')}"
        - common
      

      Given that infinite recursion is A Bad Thing™, we should either guard this use case or disallow the use of interpolation functions in the Hiera settings file.

        Attachments

        1. hi-220-init-manifest
          2 kB
          Sean Griffin
        2. hi-220-simple-init-manifest
          0.8 kB
          Sean Griffin
        3. hiera-recursive-lookup.patch
          0.8 kB
          Markus Lidel

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  chuck Charlie Sharpsteen
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: