summaryrefslogtreecommitdiff
path: root/lib/chef/node.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-05-07 12:36:30 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-18 15:37:41 -0700
commitdb62393671925bd778193c3ed8b2af49ccbb63a4 (patch)
treed363d4697fcd5bf229b4ad83c49185b44e346a40 /lib/chef/node.rb
parent05b07f669b9a06799e7e20608d1df3e5bbc2853a (diff)
downloadchef-db62393671925bd778193c3ed8b2af49ccbb63a4.tar.gz
add/fix node attributes
* fix node[:recipes] * add node[:expanded_run_list] * add node[:cookbooks]
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r--lib/chef/node.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 8c41d7e10e..617d2bab2f 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -77,6 +77,15 @@ class Chef
@run_state = {}
end
+ # after the run_context has been set on the node, go through the cookbook_collection
+ # and setup the node[:cookbooks] attribute so that it is published in the node object
+ def consume_cookbook_collection
+ return unless run_context.cookbook_collection
+ run_context.cookbook_collection.each do |cookbook_name, cookbook|
+ automatic_attrs[:cookbooks][cookbook_name][:version] = cookbook.version
+ end
+ end
+
# Used by DSL
def node
self
@@ -252,6 +261,7 @@ class Chef
# saved back to the node and be searchable
def loaded_recipe(cookbook, recipe)
fully_qualified_recipe = "#{cookbook}::#{recipe}"
+
automatic_attrs[:recipes] << fully_qualified_recipe unless Array(self[:recipes]).include?(fully_qualified_recipe)
end
@@ -362,7 +372,8 @@ class Chef
self.tags # make sure they're defined
- automatic_attrs[:recipes] = expansion.recipes
+ automatic_attrs[:recipes] = expansion.recipes.with_fully_qualified_names_and_version_constraints
+ automatic_attrs[:expanded_run_list] = expansion.recipes.with_fully_qualified_names_and_version_constraints
automatic_attrs[:roles] = expansion.roles
apply_expansion_attributes(expansion)