Skip to content

Instantly share code, notes, and snippets.

@llaurent
Created November 18, 2011 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llaurent/1376294 to your computer and use it in GitHub Desktop.
Save llaurent/1376294 to your computer and use it in GitHub Desktop.
deep merge and !merge:
default[:test1] = {
:t1 => [ "un", "deux", "trois" ],
:t2 => [ "un", "deux", "trois" ],
:t3 => [ "un", "deux", "trois" ],
:t4 => [ "un", "deux", "trois" ],
:t5 => [ "un", "deux", "trois" ]
}
Chef::Log.info("BLA1: #{node[:test1][:t1].inspect}")
Chef::Log.info("BLA2: #{node[:test1][:t2].inspect}")
Chef::Log.info("BLA3: #{node[:test1][:t3].inspect}")
Chef::Log.info("BLA4: #{node[:test1][:t4].inspect}")
Chef::Log.info("BLA5: #{node[:test1][:t5].inspect}")
[Fri, 18 Nov 2011 13:09:13 +0100] INFO: BLA1: ["un", "deux", "trois"]
[Fri, 18 Nov 2011 13:09:13 +0100] INFO: BLA2: ["un", "deux", "trois"]
[Fri, 18 Nov 2011 13:09:13 +0100] INFO: BLA3: ["un", "deux", "trois"]
[Fri, 18 Nov 2011 13:09:13 +0100] INFO: BLA4: ["un", "deux", "trois"]
[Fri, 18 Nov 2011 13:09:13 +0100] INFO: BLA5: ["un", "deux", "trois", "quatre", "cinq", "six"]
looking at http://wiki.opscode.com/display/chef/Deep+Merge i would have expected these results instead :
:t1 => [ "un", "trois" ]
:t2 => [ ]
:t3 => [ "deux", "trois" ]
:t4 => [ "quatre", "cinq", "six" ]
:t5 looks ok to me :)
name "test1"
description "test"
default_attributes "test1" => {
:t1 => [ "!merge:deux" ],
:t2 => [ "!merge:" ],
:t3 => [ "!merge:", "deux", "trois" ],
:t4 => [ "!merge:", "quatre", "cinq", "six" ],
:t5 => [ "quatre", "cinq", "six" ]
}
@llaurent
Copy link
Author

doesn't change a thing if the attributes are set like this in the cookbook:
default[:test1][:t1] = [ "un", "deux", "trois" ]
default[:test1][:t2] = [ "un", "deux", "trois" ]
default[:test1][:t3] = [ "un", "deux", "trois" ]
default[:test1][:t4] = [ "un", "deux", "trois" ]
default[:test1][:t5] = [ "un", "deux", "trois" ]

as stated here : http://tickets.opscode.com/browse/CHEF-2278?focusedCommentId=19092&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-19092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment