I'm trying to add a 'type' layer to our hiera backend so webservers can get common configuration, databases get some common configuration, etc.
Our hostname scheme is [env][number].domain.tld
where [env] and [number] are optional. [env] can be one of prod, stage, dev, or test. [number] is any digit 0-9.
I'm trying to extract from the hostname and using that in hiera.
This is what I'm using to set the global $hosttype in puppet: $hosttype = regsubst($fqdn, '(.+?)(?=(dev)|(stg)|(test)|(prod)|(\d)|(\.))', '\1')
This retrieves the fqdn, not just the . The regex works in rubular.com, but puppet 4.10 is on ruby 2.1.x and rubular is on 2.5.7. I'm new to puppet, thanks for the patience.