-
-
Save tuxfight3r/0c92107b409ceb7f74f7331d3e716287 to your computer and use it in GitHub Desktop.
Puppet hash merge and deep merge example ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matti@acrux ~/reject $ RUBYLIB=. cat - | puppet apply | |
$a = { 'abc' => 123, 'def' => 456} | |
$b = { 'abc' => 123, 'def' => 999} | |
notice dump(merge($a, $b)) | |
notice dump(merge($b, $a)) | |
notice: Scope(Class[main]): {"abc"=>"123", "def"=>"999"} | |
notice: Scope(Class[main]): {"abc"=>"123", "def"=>"456"} | |
notice: Finished catalog run in 0.07 seconds | |
matti@acrux ~/reject $ RUBYLIB=. cat - | puppet apply | |
$a = { 'a' => {'b' => [4, 5, 6], 'c' => { 'd' => 'foo' }, 'x' => [7, 8, 9] }} | |
$b = { 'a' => {'b' => [1, 2, 3], 'c' => { 'd' => 'bar' }, 'x' => 'xyz' }} | |
notice dump(deep_merge($a, $b)) | |
notice dump(deep_merge($b, $a)) | |
notice: Scope(Class[main]): {"a"=>{"b"=>["1", "2", "3"], "x"=>"xyz", "c"=>{"d"=>"bar"}}} | |
notice: Scope(Class[main]): {"a"=>{"x"=>["7", "8", "9"], "b"=>["4", "5", "6"], "c"=>{"d"=>"foo"}}} | |
notice: Finished catalog run in 0.10 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment