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

Provide agnostic mechanism for Hiera Based Data in Modules

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.0.0
    • Component/s: Docs
    • Labels:
      None
    • Template:
    • Story Points:
      2
    • Sprint:
      Platform Server 2014-11-26, Platform Server 2014-12-17, Language 2015-01-21, Language 2015-02-04

      Description

      A mechanism is wanted that allows support for hiera based data in modules such that:

      • A module author that wants this feature makes the module depend on the
        hiera - 'data-in-modules' module.
      • The use of 'hiera-data-in-modules' does not monopolize how data/lookup and injection is performed at a user site
      • The solution does not make the now available 'hiera-data-in-modules' the only possible implementation.

      The current implementation of 'hiera-data-in-modules' performs monkey patching to wire the support for a new type of hiera backend. This was required to make the logic kick in early enough.

      The idea is to use the binder/injector since it kicks in early. Two things can be bound:

      • HieraConfigManipulator - allows multiple manipulators to be bound, each is called with a hash containing the hiera.yaml config and returns a (possibly) manipulated config file.
      • HiraConfigOrganizer - is responsible for determining the order in which the HieraConfigManipulators are called.

      Initially there will be an implementation of the HieraConfigOrganizer that simply calls the manipulators in an undefined order (this because there is currently only one known implementation of hiera manipulator). If a defined order is wanted, it should be possible to bind an array with names of the manipulators to define the order in which they are called.

      This design has been discussed with R.I.Pienaar

      Idea in a bit more detail:

      class HieraConfigManipulator
        # @param [Hash] hiera_config_hash
        # @returns [Hash] - a manipulated hiera config hash
        def manipulate(hiera_config_hash)
          # ...
        end
      class HieraConfigOrganizer
         def organize(*config_manipulators)
           order =injector.lookup('Array[String]', 'hiera::manipulators::order', [])
           manipulators_hash = lookup('Hash[Ruby[HieraConfigManipulator]]', 'hiera::manipulator')
           # process manipulators
         end
      

      The module that provides a manipulator needs to make a binding - i.e. roughly do this:

      Puppet::Bindings.newbindings('hiera_data_in_modules::default') do
        bind {
          name 'hiera_data_in_modules'
          to_instance 'Puppetx::MyModule::MyManipulator'
          in_multibind('puppetx::puppet::hiera_config_manipulators')
        }
      end
      

      The code above is just a rough idea of how this is done, details to be worked out while implementing.

      The idea is to make this available in 3.6.0 when using - -parser future --binder and that it becomes standard in Puppet 4.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  henrik.lindberg Henrik Lindberg
                  QA Contact:
                  Eric Thompson
                • Votes:
                  9 Vote for this issue
                  Watchers:
                  25 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: