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

Add support for mapped paths in hiera.yaml version 5



    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.10.0
    • Component/s: Docs
    • Labels:
    • Template:
    • Epic Link:
    • Team:
      Puppet Developer Experience
    • Story Points:
    • Sprint:
      PDE 2017-03-08, PDE 2017-03-22, PDE 2017-04-05
    • Release Notes:
      New Feature
    • Release Notes Summary:
      It is now possible to expand a fact being a collection (array or hash) of values in a hiera.yaml to produce an array of paths for a given hierarchical level by using {{mapped_paths}}. This was not possible in earlier versions of hiera.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      can be covered by unit and integration tests


      The feature of being able to map an array variable to multiple paths in the hierarchy has been on the wish list for quite some time. This was originally requested in HI-257 (then rejected, because there was no easy way of supporting this in the old hiera 3 format).

      Now in hiera.yaml version 5, this is doable.

      Proposed design:
      As yet an alternative to the existing path, paths, glob, globs etc. we add a mapped_paths that operates on a fact that is a collection, and maps that into an array of paths.

        - <variable_to_map>
        - <map_var>
        - <template_string>

      As an example, a fact named $services contains the array ["a", "b", "c"], then this configuration:

      - name: Example
        mapped_paths: [services, tmp, "service/%{tmp}/common.yaml"]

      has the same results as if paths had been specified to be [service/a/common.yaml, service/b/common.yaml, service/c/common.yaml].

      The operation is basically a call to map with the following rules:

      • The collection is mapped and each entry is assigned in turn to the given variable name
      • The given (temporary) variable name is only available locally in the specific mapped_paths.
      • the given variable may shadow an outer variable
      • If the collection is a hash, each iteration produces a key-value tuple and assigns it to the named variable
      • If the referenced collection is not a collection is is turned into a one element array before mapping.


          Issue Links



              Unassigned Unassigned
              henrik.lindberg Henrik Lindberg
              0 Vote for this issue
              7 Start watching this issue



                  Zendesk Support