group nodes by fqdn prefix or value

asked 2018-04-26 14:51:38 -0600

Marc Schöchlin gravatar image

I would like to group some nodes by a common regex citeria using hiera to share options for a group of hosts.

The configuration should act like this:

  1. lookup common.yaml
  2. lookup a definition of regex and corresponding yaml files: group/%{matchname}.yaml
  3. lookup "nodes/%{trusted.certname}.yaml"

The second definition should work like this:

/lb-prod-(de|us)-\d\d\d\.srv.foo.bar/ : loadbalancers
/web-prod-(de|us)-\d\d\d\.srv.foo.bar/ : webservers

Example: If the {trusted.certname}is lb-prod-de-111.srv.foo.bar, the second yaml file in the hierarchy should be group/loadbalancers.yaml.

Is that possible?

edit retag flag offensive close merge delete

Comments

https://github.com/jjulien/hiera-regex seems to provide a compare solution.

Marc Schöchlin gravatar imageMarc Schöchlin ( 2018-04-26 14:52:06 -0600 )edit