1

I'm working on moving over a node inheritance tree to hiera. Presently working on the hierarchy. Prior to hiera, my nodes had a hierarchy as such

base
  pre-prod
    qa
      nodes
    staging
      nodes
    development
      nodes
  prod
    nodes

Now I'm trying to get the same tier with hiera. Starting out I have this

:hierarchy:
  - base
  - "%{environment}"
  - "%{clientcert}"

but I need another level to capture pre-prod and prod. My thought would be to add an entry to puppet.conf, something like

[agent]
realm = pre-prod

then

:hierarchy:
  - base
  - "%{realm}"
  - "%{environment}"
  - "%{clientcert}"

A couple of questions

  1. Are you allowed to place arbitrary properties into puppet.conf?
  2. Will hiera see the realm property?
quickshiftin
  • 2,025
  • 5
  • 27
  • 41

1 Answers1

1

You could do that on the client side, with a custom fact instead of a puppet.conf setting. However, I'd say do it on the server side, in the Hiera data. The trick that I use for something similar is as follows:

  1. Set something in the Hiera data at the clientcert level, for each server. In your case:

    realm: "pre-prod"
    
  2. Grab that variable into global scope via Hiera in site.pp, before your hiera_include:

    $realm = hiera(realm)
    
    hiera_include(classes)
    
  3. The variable's been fetched from the clientcert.yaml file, and will now be used in the lookups that occur from your hiera_include, pulling from pre-prod.yaml based on the "%{realm}" config in your hierarchy.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248