Today looking for a solution to this I came up with a nice solution. I know
this is old but I'm posting it just in case is useful for somebody:
on hiera.yaml:
:hierarchy:
- 'host/%{::domain}/%{::hostname}'
- 'domain/%{::domain}'
- 'role/%{system_role}'
- 'common'
on site.pp
node
you might want to explicitly top-scope role, ie.
$::role = 'nameserver'
Not sure if that will matter in this case, but I don't think it can hurt.
As an aside, we set our role variable with facter.d on the nodes
themselves, as we don't have hostnames that easily work out to roles.
On