Skip to content

Commit

Permalink
Chef client accepts nil run list to load run list from server [closes h…
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jul 26, 2011
1 parent 6217a91 commit ed8bf34
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.8.3 (unreleased)

- Fix SSH `exec!` to inherit proper `$PATH`. [GH-426]
- Chef client now accepts an empty (`nil`) run list again. [GH-429]

## 0.8.2 (July 22, 2011)

Expand Down
16 changes: 11 additions & 5 deletions lib/vagrant/provisioners/chef.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Config < Vagrant::Config::Base
attr_accessor :no_proxy
attr_accessor :binary_path
attr_accessor :binary_env
attr_accessor :run_list
attr_writer :run_list

def initialize
@provisioning_path = "/tmp/vagrant-chef-#{self.class.get_and_update_counter}"
Expand All @@ -107,15 +107,21 @@ def initialize
@no_proxy = nil
@binary_path = nil
@binary_env = nil
@run_list = []
@run_list = nil
end

# This returns the json that is merged with the defaults and the
# user set data.
def merged_json
{ :instance_role => "vagrant",
:run_list => run_list
}.merge(json || {})
original = { :instance_role => "vagrant" }
original[:run_list] = @run_list if @run_list
original.merge(json || {})
end

# Returns the run list, but also sets it up to be empty if it
# hasn't been defined already.
def run_list
@run_list ||= []
end

# Adds a recipe to the run list
Expand Down
11 changes: 11 additions & 0 deletions test/vagrant/provisioners/chef_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class ChefProvisionerTest < Test::Unit::TestCase
assert result !~ /"json":/
end

should "not include the 'run_list' key in json if not accessed" do
result = @config.merged_json
assert !result.has_key?(:run_list)
end

should "include the 'run_list' key in json if it is set" do
@config.run_list << "foo"
result = @config.merged_json
assert result.has_key?(:run_list)
end

should "provide accessors to the run list" do
@config.run_list << "foo"
assert !@config.run_list.empty?
Expand Down

0 comments on commit ed8bf34

Please sign in to comment.