summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2012-06-25 16:14:25 -0700
committerDaniel DeLeo <dan@opscode.com>2012-06-25 16:14:25 -0700
commitfafa4063f0ac5f2bd9997ef956b6a3a03de95669 (patch)
tree42765029f0a024ee295bb1ec247ab434047e4227
parent7928f289c727fbbc031c2f8107df12a7134fcada (diff)
parent4ea42e7fe5377547cbb802ff0233307a5e444820 (diff)
downloadchef-fafa4063f0ac5f2bd9997ef956b6a3a03de95669.tar.gz
Merge branch 'run_list_tree'
-rw-r--r--chef/lib/chef/run_list/run_list_expansion.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/chef/lib/chef/run_list/run_list_expansion.rb b/chef/lib/chef/run_list/run_list_expansion.rb
index d4bad472a9..690eb3392b 100644
--- a/chef/lib/chef/run_list/run_list_expansion.rb
+++ b/chef/lib/chef/run_list/run_list_expansion.rb
@@ -49,6 +49,12 @@ class Chef
# to fetch roles from their correct location.
attr_reader :source
+ # Returns a Hash of the form "including_role" => "included_role_or_recipe".
+ # This can be used to show the expanded run list (ordered) graph.
+ # ==== Caveats
+ # * Duplicate roles are not shown.
+ attr_reader :run_list_trace
+
def initialize(environment, run_list_items, source=nil)
@environment = environment
@missing_roles_with_including_role = Array.new
@@ -62,6 +68,7 @@ class Chef
@recipes = Chef::RunList::VersionedRecipeList.new
@applied_roles = {}
+ @run_list_trace = Hash.new {|h, key| h[key] = [] }
end
# Did we find any errors (expanding roles)?
@@ -135,6 +142,8 @@ class Chef
def expand_run_list_items(items, included_by="top level")
if entry = items.shift
+ @run_list_trace[included_by.to_s] << entry.to_s
+
case entry.type
when :recipe
recipes.add_recipe(entry.name, entry.version)
@@ -144,7 +153,7 @@ class Chef
apply_role_attributes(role)
end
end
- expand_run_list_items(items)
+ expand_run_list_items(items, included_by)
end
end