lib/vagrant/provisioners/chef.rb in vagrantup-0.9.1 vs lib/vagrant/provisioners/chef.rb in vagrantup-0.9.2
- old
+ new
@@ -113,15 +113,15 @@
attr_accessor :binary_path
attr_accessor :binary_env
attr_accessor :attempts
attr_writer :run_list
- def initialize
- @attempts = 1
- @json = {}
- @log_level = :info
- end
+ # Provide defaults in such a way that they won't override the instance
+ # variable. This is so merging continues to work properly.
+ def attempts; @attempts || 1; end
+ def json; @json ||= {}; end
+ def log_level; @log_level || :info; end
# This returns the json that is merged with the defaults and the
# user set data.
def merged_json
original = { :instance_role => "vagrant" }
@@ -143,9 +143,15 @@
# Adds a role to the run list
def add_role(name)
name = "role[#{name}]" unless name =~ /^role\[(.+?)\]$/
run_list << name
+ end
+
+ def validate(env, errors)
+ super
+
+ errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if json.has_key?(:vagrant)
end
def instance_variables_hash
# Overridden so that the 'json' key could be removed, since its just
# merged into the config anyways