I am trying to wrap my head around how I can transition from something I am doing in my large site.pp file into a structure I can use in hiera. It isn't clear to me from reading the puppet docs, exactly how the hiera data is evaluated and when it fits into the picture. I have recently upgraded from puppet 2.7.x to 3.3.x. This includes the hiera as part of standard package, so I wanted to finally look at using this since it should make my setup easier to read/understand.
I am using to support systems several external organizations. This includes configuring systems unique to each organization. At the top of my site.pp I have a structure like below. Which I use to set facts for each organization based on a regular expression that matches against the clientcert fact which are configured and issued in a way that they will reliably identify each organization.
# match organization
case $::clientcert {
/.*example1.org/ :
{ $snmp_ro_community='...'
$snmp_location='Example Org 1'
... }
/.*example2.org/ :
{ $snmp_ro_community='...'
$snmp_location='Example Org 2'
... }
/.*example3.org/ :
{ $snmp_ro_community='...'
$snmp_location='Example Org 3'
... }
/.*example4.org/ :
{ $snmp_ro_community='...'
$snmp_location='Example Org 4'
... }
}
I browsing through examples I don't see any way to do any kind of pattern matching in my hiera.yaml file. I suspect I must be missing something obvious though.
I do not want to rely on a custom fact for this. I prefer to stick with the client certificate, since I am certain this will correctly identify the organization and system and has been confirmed using strong cryptography. I don't want to give the one organizations values to another organization.