Can hiera match on a partial fact

asked 2018-04-05 18:36:23 -0500

UBPClaw gravatar image

I need to install and configure a daemon on our servers that will have different settings based on what location the server is. Our server naming convention denotes location-function-number-then if its production or dev and if its physical or virtual.

So a production file server in Chicago that is a VM would be chic-file-01-pv

Can Hiera match a hostname on the first three letters in the hostname? There is a slight variation on the first part that lists location because reasons. Or would it be better to use a case declaration and set a variable using a regex?

edit retag flag offensive close merge delete


I do not think heira can do this. Your case option can work. Alternatively why not make custom fact based on the certname? Then you can use that fact to do what you need.

ffalor gravatar imageffalor ( 2018-04-05 22:17:44 -0500 )edit

The other (better) option would be to just identify datacenter based on some value. Would I need to build a custom fact to do that? Then I could have hiera match on dc1, dc2, etc

UBPClaw gravatar imageUBPClaw ( 2018-04-06 09:08:23 -0500 )edit

Yes i would make a custom fact that takes the client certname and breaks it down. Then have heira give different settings based on the location.

ffalor gravatar imageffalor ( 2018-04-10 00:29:41 -0500 )edit