hiera_include equivalent for resource types
I've ended up using create_resources. Essentially it provides the ability to map defined types to nodes with hiera, in much the same way hiera_include
does with classes out of the box.
With this setup I can declare any number of file
resource types at any level of the hierarchy, plus the configuration is all in hiera datasources.
/etc/hiera.yaml
:hierarchy:
- defaults
- "%{environment}"
/var/lib/hiera/defaults.yaml
classes:
- hiera_file_wrapper
hiera_file:
hiera-two:
path: /home/quickshiftin/hiera-two
ensure: file
content: 'Hiera two'
/var/lib/hiera/production.yaml
hiera_file:
hiera-baby:
path: /home/quickshiftin/hiera-baby
ensure: file
content: 'Hiera baby!
modules/hiera_file_wrapper/manifestes/init.pp
class hiera_file_wrapper()
{
create_resources(file, hiera_hash('hiera_file'))
}
manifestes/site.pp
hiera_include('classes')