hiera_hash not merging

asked 2017-07-20 04:04:48 -0500

Wraxter gravatar image

I can't seem to get hiera_hash to actually merge my hashes.

Here's my setup:

init.pp (just the relevant stuff)

class kong (
   $api_config,
) inherits kong::params {

class {'kong::install':
    package => $package,
    version => $version,
  }
  $hiera_hash_api_config = hiera_hash('kong::api_config')

class {'kong::config':
    api_config                     => $hiera_hash_api_config,
  }

config.pp

class kong::config(
  $api_config                     = $kong::api_config,
) {

  file { "${post_install_path}/kong-init.py":
    ensure  => file,
    content => template('kong/kong-init.py.erb'),
    owner   => $kong_user,
    group   => $kong_group,
    mode    => '0755',
    require => File[$post_install_path],
  }

And here are the YAML files

hieradata/app_land/application/dev.yaml

kong::api_config:
  api1:
    upstream_url: 'url'
  api2:
    upstream_url: 'url'
  api3:
    upstream_url: 'url'

hieradata/application/kong.yaml

kong::api_config:
  api1:
    name: "api1"
    strip_uri: "True"
    unsecured:
      methods: "DELETE, POST, GET, OPTIONS"
      plugins:
        cors:
          config.methods: "DELETE, POST, GET"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"
    userinfo:
      methods: "GET, OPTIONS"
      plugins:
        cors:
          config.methods: "GET"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"
        acl:
          config.whitelist: "PUBLIC"
  api2:
    name: "api2"
    strip_uri: "True"
    unsecured:
      methods: "GET"
      plugins:
        cors:
          config.methods: "GET"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"
        acl:
          config.whitelist: "PRIVATE"
        key-auth:
          config.hide_credentials: "True"
    secured:
      methods: "POST, DELETE"
      plugins:
        cors:
          config.methods: "GET"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"
        acl:
          config.whitelist: "PRIVATE"
  api3:
    name: "api3"
    strip_uri: "True"
    default:
      methods: "OPTIONS, GET, POST, DELETE, PUT"
      group: "PUBLIC"
      plugins:
        cors:
          config.methods: "GET, POST, DELETE, PUT"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"
    clients:
      methods: "GET"
      group: "PRIVATE"
      plugins:
        cors:
          config.methods: "GET"
          config.allowed_origin: "%{hiera('kong::allowed_origin')}"

and hiera.yaml hierachy:

:hierarchy:
  - unique/%{::unique}
  - app_land%{::application}/%{::landscape}
  - application/%{::application}

When I run puppet, the end result is the upstreamurl defined in the dev.yaml appears fine, but all of the values in kong.yaml are undefined. I can't seem to figure out why. It had been working fine when api1, api2 and api3 each had their own config hash, and had 'hierahash' applied to them. But now that I've combined them, it seems to fail. I'm fairly new to puppet, so apologies if im missing something obvious. I just can't seem to wrap my head around whats wrong

edit retag flag offensive close merge delete