Puppet Hiera 5 Lookup function value -


i testing blog post last sample in system. lookup command giving different result. understand why

https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php

for lookup command, getting value

% puppet lookup --environmentpath environments classifier::classes --- - sysadmins - nagios - webserver 

here config:

# cat /etc/puppetlabs/puppet/hiera.yaml version: 5 defaults:   datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"   data_hash: yaml_data hierarchy:    - name: "other yaml hierarchy levels"      paths:         - "groups/%{facts.hostname}.yaml"         - "os/%{facts.os.family}.yaml"         - "common.yaml" 

data files:

# cat "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml" classifier::classes:   - nagios   - --sensu   - webserver  cat "/etc/puppetlabs/code/environments/production/hieradata/common.yaml" --- version: 5  classifier::classes:   - sensu   - sysadmins 

my lookup command gives value:

#  puppet lookup --environmentpath environments classifier::classes                                        --- - nagios - "--sensu" - webserver 

debug command output:

# puppet lookup --environmentpath environments --explain classifier::classes searching "lookup_options"   global data provider (hiera configuration version 5)     using configuration "/etc/puppetlabs/puppet/hiera.yaml"     hierarchy entry "other yaml hierarchy levels"       merge strategy hash         path "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml"           original path: "groups/%{facts.hostname}.yaml"           no such key: "lookup_options"         path "/etc/puppetlabs/code/environments/production/hieradata/os/redhat.yaml"           original path: "os/%{facts.os.family}.yaml"           path not found         path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"           original path: "common.yaml"           no such key: "lookup_options"   module "classifier" not found searching "classifier::classes"   global data provider (hiera configuration version 5)     using configuration "/etc/puppetlabs/puppet/hiera.yaml"     hierarchy entry "other yaml hierarchy levels"       path "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml"         original path: "groups/%{facts.hostname}.yaml"         found key: "classifier::classes" value: [           "nagios",           "--sensu",           "webserver"         ] 
  1. why getting different output?
  2. why debug command not giving 'merge strategy ' message?

thanks sr


as per matt response have added in common.yaml file.

# puppet lookup --environmentpath environments classifier::classes --- - sysadmins - nagios - webserver 

there several differences between ripieenar did , did (lookup/data provider version, module data vs. environment data, etc.), primary cause of difference in output lack of using "deep_merge" in merge strategy. after installing deep_merge gem on puppetserver, can change lookup use strategy instead of hash.

# /etc/puppetlabs/code/environments/production/hieradata/common.yaml lookup_options:   classifier::classes:     merge:       strategy: deep       knockout_prefix: "--"       unpack_arrays: ","       sort_merge_arrays: true 

that give same output posts in blog.


Comments

  1. When I am running puppet lookup command

    /opt/puppetlabs/bin/puppet lookup --explain demo::configuration::phpini::memory_limit --environment staging --node puppetsr7.demo.com


    Searching for "lookup_options"
    Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "Per-node data (yaml version)"
    Path "/etc/puppetlabs/code/environments/staging/data/puppetsr7.perficientdcsdemo.com.yaml"
    Original path: "environments/%{::environment}/data/%{::trusted.certname}.yaml"
    No such key: "lookup_options"
    Environment Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/code/environments/staging/hiera.yaml"
    Merge strategy hash
    Hierarchy entry "Per-node data (yaml version)"
    Path "/etc/puppetlabs/code/environments/staging/data/puppetsr7.perficientdcsdemo.com.yaml"
    Original path: "/etc/puppetlabs/code/environments/staging/data/%{::trusted.certname}.yaml"
    No such key: "lookup_options"
    Hierarchy entry "Test1"
    Path "/etc/puppetlabs/code/environments/staging/data/puppetsr7.perficientdcsdemo.com.yaml"
    Original path: "/etc/puppetlabs/code/environments/staging/data/%{::clientcert}.yaml"
    No such key: "lookup_options"
    Module "perficient" Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/code/environments/staging/modules/perficient/hiera.yaml"
    Hierarchy entry "Per-node data (yaml version)"
    Path "/etc/puppetlabs/code/environments/staging/data/puppetsr7.perficientdcsdemo.com.yaml"
    Original path: "data/%{::trusted.certname}.yaml"
    No such key: "lookup_options"
    Searching for "perficient::configuration::phpini::memory_limit"
    Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "Per-node data (yaml version)"
    Path "/etc/puppetlabs/code/environments/staging/data/puppetsr7.perficientdcsdemo.com.yaml"
    Original path: "environments/%{::environment}/data/%{::trusted.certname}.yaml"
    Found key: "perficient::configuration::phpini::memory_limit" value: 22



    I am getting the value 22, but when running the puppet agent command on node, value for memory limit does not getting changed. can you help ?

    ReplyDelete

Post a Comment

Popular posts from this blog

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -

ios - Align baselines with characters in large line heights with Text Kit -