Q:

Nested YAML for hiera in puppet

I am working on designing a puppet architecture for our company.  I really like the idea of hiera and YAML files to classify my nodes.  However, I would really like to be able to either apply YAML files that aren't based on facts or import YAML files into another YAML file.
For example NodeA.yaml
---
include webserver.yaml
include public.yaml

classes:
etc. . . 

This would allow me to reuse my code as much as possible. That way when I make a change to my web server configs, I only have to do it in one file instead of every node's YAML file.
I'm open to other solutions as well.

A:

YAML does not support import or include
(not recomended) You can use loadyaml from stdlib module to achieve desired functionality. Check this example of using loadyaml function.
You can easily achieve expected functionality just by designing a proper hiera hierarchy. I do not understand why you do not want to use facter facts? e.g: on each node define custom facter fact location. Next define a hiera hierarchy: 
:hierarchy:
  - "%{::location}"/"%{::fqdn}"
  - "%{::location}"/common
  - common 

Next in file location_1/node1.yaml you define data specific only for that node1. In file location_1/common.yaml you define data common for all nodes in location_1. In common.yaml you define data common for all nodes. 
If some data is common for all nodes you define it once in common.yaml and that's all. You do not have to redundantly define it in every node's yaml file.

