Ask Your Question
2

Deep merge not working on puppet 4.1

asked 2015-06-15 17:08:31 -0600

Thab gravatar image

updated 2015-06-16 02:26:04 -0600

Hi i have a module ssh which uses hieradata

i wish to have some basic settings in my common.yaml and have overrides in host.yaml.

but when i add the variable to the host yaml file the end result is that my config file only has this value.

setup:

common.yaml

ssh::settings:
  setting1: 'value1'
  setting2: 'value2'

example.com.yaml

ssh::settings:
  setting1: 'values'

my hiera.yaml file has merge behaviour set to: deeper

deep_merge gem is installed for puppetserver

expected result in file:

 setting1  values
 setting2  'value2'

result i get:

setting1 values

when i do a hiera lookup on the commandline it gives me the correct result.

setting1 => values
setting2 => value2

anyone has any idea what might be wrong?

====

edit

extra info:

hiera command used:

hiera -d ssh::settings ::environment=test ::clientcert=example.com --hash -c /etc/puppetlabs/code/hiera.yaml

in the module:

class ssh (
  $settings = hiera_hash('ssh::settings'),
) {

.... }

edit retag flag offensive close merge delete

Comments

Can you post the hiera command line you're using as well as the Puppet code that performs the hiera lookup?

GregLarkin gravatar imageGregLarkin ( 2015-06-16 00:42:43 -0600 )edit

hi, see dited info in the question

Thab gravatar imageThab ( 2015-06-16 02:24:58 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-06-16 03:00:07 -0600

Thab gravatar image

updated 2015-06-17 02:17:23 -0600

Figured it out thanks to the help of a friend..

turns out the problem was in the class:

    class ssh (
  $settings = hiera_hash('ssh::settings'),
) {

In this setup puppet will still try to perform the autolookup before it uses the default value. which in this case because puppet does not do merging.. returns the one value.

this can be fixed be placing the var in the class itself instead of the param section. ( or renaming it in the param section to a name that does not pop up in hiera.

class ssh (
) {
  $settings = hiera_hash('ssh::settings'),
  ...
}
edit flag offensive delete link more
1

answered 2015-06-16 02:46:57 -0600

rswarts gravatar image

Class ssh does a non-merging lookup of its $settings. Because it can find it, it ignores your default of hiera_hash('ssh::settings'), instead taking the non-merging result of your lookup.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-15 17:08:31 -0600

Seen: 557 times

Last updated: Jun 17 '15