hiera interpolation

asked 2017-06-12 05:14:01 -0600

rssh22 gravatar image

I have module called mdwcfg which is used for hiera configuration:

mdwcfg/hiera.yaml:

---
version: 5
defaults:
 datadir: data
 data_hash: yaml_data

hierarchy:
  - name: "wld-pil-03"
    path: "wld-pil-03.yaml"
  - name: "wld-pil-04"
    path: "wld-pil-04.yaml"
  - name: "jdk" 
    path: "jdk.yaml"
  - name: "common"
    path: "common.yaml"

mdwcfg/data/wld-pil-04.yaml:

---
domain_env: 'pil'
domain_number: '04'
mdwcfg::domain_env:                   &domain_env                    'pil'
mdwcfg::domain_number:                &domain_number                 '04'
mdwcfg::domain_name:                  &domain_name                   "wld-%{mdwcfg::domain_env}-%{mdwcfg::domain_number}"

and I create a test file /tmp/kk.pp

include mdwcfg

$a = lookup('mdwcfg::domain_name')

notify{"a: ${a}":}

puppet can't interpolate the variable mdwcfg:domain_name

/opt/puppetlabs/bin/puppet apply /tmp/kk.pp --modulepath=/etc/puppetlabs/code/environments/production/modules/ --debug

....
Debug: Facter: resolving Xen facts.
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: importing '/etc/puppetlabs/code/environments/production/modules/mdwcfg/manifests/init.pp' in environment production
Debug: Automatically imported mdwcfg from mdwcfg into production
Warning: Defining "data_provider": "hiera" in metadata.json is deprecated. It is ignored since a 'hiera.yaml' with version >= 5 is present
   (in /etc/puppetlabs/code/environments/production/modules/mdwcfg/metadata.json)
Warning: Module 'mdwcfg': Hierarchy entry "wld-pil-04" must use keys qualified with the name of the module
Warning: Module 'mdwcfg': Hierarchy entry "wld-pil-04" must use keys qualified with the name of the module
Warning: Undefined variable 'domain_env';
   (file & line not available)
Warning: Undefined variable 'domain_number';
   (file & line not available)
Debug: Automatic Parameter Lookup of 'mdwcfg::domain_name
  Searching for "lookup_options"
    Global Data Provider (hiera configuration version 5)
      No such key: "lookup_options"
    Module "mdwcfg" Data Provider (hiera configuration version 5)
      Using configuration "/etc/puppetlabs/code/environments/production/modules/mdwcfg/hiera.yaml"
      Merge strategy hash
        Hierarchy entry "wld-pil-03"
          Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/wld-pil-03.yaml"
            Original path: "wld-pil-03.yaml"
            No such key: "lookup_options"
        Hierarchy entry "wld-pil-04"
          Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/wld-pil-04.yaml"
            Original path: "wld-pil-04.yaml"
            No such key: "lookup_options"
        Hierarchy entry "jdk"
          Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/jdk.yaml"
            Original path: "jdk.yaml"
            No such key: "lookup_options"
        Hierarchy entry "common"
          Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/common.yaml"
            Original path: "common.yaml"
            No such key: "lookup_options"
  Searching for "mdwcfg::domain_name"
    Global Data Provider (hiera configuration version 5)
      No such key: "mdwcfg::domain_name"
    Module "mdwcfg" Data Provider (hiera configuration version 5)
      Using configuration "/etc/puppetlabs/code/environments/production/modules/mdwcfg/hiera.yaml"
      Hierarchy entry "wld-pil-03"
        Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/wld-pil-03.yaml"
          Original path: "wld-pil-03.yaml"
          No such key: "mdwcfg::domain_name"
      Hierarchy entry "wld-pil-04"
        Path "/etc/puppetlabs/code/environments/production/modules/mdwcfg/data/wld-pil-04.yaml"
          Original path: "wld-pil-04.yaml"
          Interpolation on "wld-%{mdwcfg::domain_env}-%{mdwcfg::domain_number}"
            Global Scope
            Global Scope
          Found key: "mdwcfg::domain_name" value: "wld--"
Debug: Lookup of 'mdwcfg::domain_name'
  Searching for "lookup_options"
    Global Data Provider (hiera configuration version 5)
      No such key: "lookup_options"
    Module "mdwcfg" Data Provider (hiera configuration version 5)
      Using configuration "/etc/puppetlabs/code/environments/production/modules/mdwcfg/hiera.yaml"
      Merge strategy hash
        Hierarchy entry "wld-pil-03"
          Path "/etc/puppetlabs ...
(more)
edit retag flag offensive close merge delete