summaryrefslogtreecommitdiff
path: root/lib/chef/policy_builder/policyfile.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2014-01-23 15:45:38 -0800
committerdanielsdeleo <dan@opscode.com>2014-01-23 17:14:56 -0800
commit43d8c8fbe5c69f7ebb9cb462dd7de453bea00f4a (patch)
treee3887132a7460f4aad6913dd6bec232c42dbfb28 /lib/chef/policy_builder/policyfile.rb
parent7ef17a8e4cb03bc37ab345f5dfe85a6110573711 (diff)
downloadchef-43d8c8fbe5c69f7ebb9cb462dd7de453bea00f4a.tar.gz
Add public API for expanding run_list in Chef::Client
External projects like chefspec need to do this separately so they can inject custom behavior before/after.
Diffstat (limited to 'lib/chef/policy_builder/policyfile.rb')
-rw-r--r--lib/chef/policy_builder/policyfile.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index 3c89f810fa..4373c36c86 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -51,7 +51,7 @@ class Chef
class PolicyfileError < StandardError; end
- RunListExpansionIsh = Struct.new(:recipes)
+ RunListExpansionIsh = Struct.new(:recipes, :roles)
attr_reader :events
attr_reader :node
@@ -100,10 +100,14 @@ class Chef
nil
end
- # Policyfile gives you the run_list already expanded, no expansion is
- # performed here.
+ # Policyfile gives you the run_list already expanded, but users of this
+ # class may expect to get a run_list expansion compatible object by
+ # calling this method.
+ #
+ # === Returns
+ # RunListExpansionIsh:: A RunListExpansion duck type
def run_list_expansion
- nil
+ run_list_expansion_ish
end
## PolicyBuilder API ##
@@ -134,6 +138,7 @@ class Chef
node.consume_external_attrs(ohai_data, json_attribs)
+ expand_run_list
apply_policyfile_attributes
Chef::Log.info("Run List is [#{run_list}]")
@@ -162,6 +167,13 @@ class Chef
run_context
end
+ def expand_run_list
+ node.run_list(run_list)
+ node.automatic_attrs[:roles] = []
+ node.automatic_attrs[:recipes] = run_list_expansion_ish.recipes
+ run_list_expansion_ish
+ end
+
## Internal Public API ##
def sync_cookbooks
@@ -190,13 +202,10 @@ class Chef
cookbook, recipe = parse_recipe_spec(recipe_spec)
"#{cookbook}::#{recipe}"
end
- RunListExpansionIsh.new(recipes)
+ RunListExpansionIsh.new(recipes, [])
end
def apply_policyfile_attributes
- node.run_list(run_list)
- node.automatic_attrs[:roles] = []
- node.automatic_attrs[:recipes] = run_list_expansion_ish.recipes
node.attributes.role_default = policy["default_attributes"]
node.attributes.role_override = policy["override_attributes"]
end