diff options
author | Thom May <tmay@expedia.com> | 2013-08-12 18:08:31 +0100 |
---|---|---|
committer | Thom May <tmay@expedia.com> | 2013-08-12 18:08:31 +0100 |
commit | 96f82ac6a95356b3c3dc54306dfa020ea59829ff (patch) | |
tree | 5eebbec300060db2859fc52f1bfe50d10cf1280e /lib/chef/node.rb | |
parent | 62148fe95a1ce46f1de319b52dea8382c6e5d9e9 (diff) | |
download | chef-96f82ac6a95356b3c3dc54306dfa020ea59829ff.tar.gz |
CHEF-4443 - Always save the correct run list
As per Dan's suggestions, use a primary run_list and an override, and
take care to ensure that the correct one is used to save the node.
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r-- | lib/chef/node.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 6bd2226ac8..f73628fdf5 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -42,7 +42,7 @@ class Chef def_delegators :attributes, :keys, :each_key, :each_value, :key?, :has_key? - attr_accessor :recipe_list, :run_state, :run_list + attr_accessor :recipe_list, :run_state, :override_runlist # RunContext will set itself as run_context via this setter when # initialized. This is needed so DSL::IncludeAttribute (in particular, @@ -63,7 +63,8 @@ class Chef @name = nil @chef_environment = '_default' - @run_list = Chef::RunList.new + @primary_runlist = Chef::RunList.new + @override_runlist = Chef::RunList.new @attributes = Chef::Node::Attribute.new({}, {}, {}, {}) @@ -252,10 +253,19 @@ class Chef run_list.include?("role[#{role_name}]") end + def primary_runlist + @primary_runlist + end + + def override_runlist(*args) + args.length > 0 ? @override_runlist.reset!(args) : @override_runlist + end + # Returns an Array of roles and recipes, in the order they will be applied. # If you call it with arguments, they will become the new list of roles and recipes. def run_list(*args) - args.length > 0 ? @run_list.reset!(args) : @run_list + rl = @override_runlist.empty? ? @primary_runlist : @override_runlist + args.length > 0 ? rl.reset!(args) : rl end # Returns true if this Node expects a given role, false if not. @@ -395,7 +405,7 @@ class Chef "default" => attributes.combined_default, "override" => attributes.combined_override, #Render correctly for run_list items so malformed json does not result - "run_list" => run_list.run_list.map { |item| item.to_s } + "run_list" => @primary_runlist.run_list.map { |item| item.to_s } } result end |