Hiera Deep Merge inside create_resources

asked 2018-09-17 10:36:37 -0500

mtenrero gravatar image

Hello, I'm trying to do a merge inside create_resources class but the hash is not being merged correctly, I think the guilty is the hash name for each instance to be configured.

Hiera Global Config

version: 5
hierarchy:
  - name: "Common Merge Policy"
    path: "C:/ProgramData/PuppetLabs/code/environments/hieradata/merge_policy.yaml"

  - name: "Node specific configuration"
    path: "C:/ProgramData/PuppetLabs/code/environments/hieradata/%{trusted.certname}.yaml"

  - name: "AppServer specific configuration"
    path: "C:/ProgramData/PuppetLabs/code/environments/%{environment}/hieradata/config.yaml"

Merge Policy

lookup_options:
    "^config::config_sites::(.*)::siteparams$":
        merge:
            strategy: deep

Common config

config::config_sites:
    siteparams:
        controller: 8000
        dispatcher: 8102

Node Specific config

config::config_sites:
    INSTANCE1:
        siteparams:
            controller: 4000

Crete_Resources called class

define m4appconfig::config_sites (
  $siteparams   = {},
  $servers = {}
  ){

The problem is that the retrieved hash is the defined in Node Specific YAML and it's not merged with the Common one in order to populate the whole hash with the default value for the dispatcher key.

I think this could happen because in the node specific YAML i'm specifying a list of instance to configure and inside each instance in the hash I hold all the customized config for each one.

I'm doing this in the correct way? Or should I change my approach?.

Thank you.

edit retag flag offensive close merge delete