puppetlabs/puppet — pull request #1217 by ripienaar (2012-10-08 19:36:59+00:00)
Title: 16856 - Add a module data directory and hiera backend to consume it

While hiera does a decent job of separating code and data for users
it is quite difficult for module authors to use hiera to create reusable
modules. This is because the puppet backend is optional and even when
it is loaded the module author cannot influence the hierarchy.

With this commit we add a new module_data backend that loads data from
within a module and allow the module author to set a hierarchy for this
data.

The goal of this backend is to allow module authors to specify true
module default data in their modules but still allow users to override
the data using the standard method - especially useful with the puppet 3
hiera integration.

This backend is always loaded as the least important tier in the
hierarchy - unless a user choose to put it somewhere specific, but this
backend will always be enabled.

Given a module layout:

your_module
├── data
│ ├── hiera.yaml
│ └── osfamily
│ ├── Debian.yaml
│ └── RedHat.yaml
└── manifests
└── init.pp

The hiera.yaml is optional and includes only 1 key, the hierarchy:

---
:hierarchy:
- osfamily/%{::osfamily}
- common

The example above would be the default if no hiera.yaml is specified.

The data directory is then a standard Hiera data store.