diff --git a/lib/vagrant/plugin/v2/config.rb b/lib/vagrant/plugin/v2/config.rb index a74eb670c..f3db8e610 100644 --- a/lib/vagrant/plugin/v2/config.rb +++ b/lib/vagrant/plugin/v2/config.rb @@ -90,12 +90,10 @@ module Vagrant # Called after the configuration is finalized and loaded to validate # this object. # - # @param [Environment] env Vagrant::Environment object of the - # environment that this configuration has been loaded into. This - # gives you convenient access to things like the the root path - # and so on. - # @param [ErrorRecorder] errors - def validate(env, errors) + # @param [Machine] machine Access to the machine that is being + # validated. + # @return [Hash] + def validate(machine) end end end diff --git a/plugins/provisioners/chef/config/base.rb b/plugins/provisioners/chef/config/base.rb index 67bc2283a..f097d03b2 100644 --- a/plugins/provisioners/chef/config/base.rb +++ b/plugins/provisioners/chef/config/base.rb @@ -52,12 +52,6 @@ module VagrantPlugins 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 diff --git a/plugins/provisioners/chef/config/chef_client.rb b/plugins/provisioners/chef/config/chef_client.rb index ea734cc86..7d89aa5fd 100644 --- a/plugins/provisioners/chef/config/chef_client.rb +++ b/plugins/provisioners/chef/config/chef_client.rb @@ -22,12 +22,16 @@ module VagrantPlugins def file_backup_path; @file_backup_path || "/srv/chef/cache"; end def encrypted_data_bag_secret; @encrypted_data_bag_secret || "/tmp/encrypted_data_bag_secret"; end - def validate(env, errors) - super + def validate(machine) + errors = [] + errors << I18n.t("vagrant.config.chef.server_url_empty") if \ + !chef_server_url || chef_server_url.strip == "" + errors << I18n.t("vagrant.config.chef.validation_key_path") if \ + !validation_key_path + errors << I18n.t("vagrant.config.chef.run_list_empty") if \ + @run_list && @run_list.empty? - errors.add(I18n.t("vagrant.config.chef.server_url_empty")) if !chef_server_url || chef_server_url.strip == "" - errors.add(I18n.t("vagrant.config.chef.validation_key_path")) if !validation_key_path - errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if @run_list && @run_list.empty? + { "chef client provisioner" => errors } end end end diff --git a/plugins/provisioners/chef/config/chef_solo.rb b/plugins/provisioners/chef/config/chef_solo.rb index 351e10fef..552af423b 100644 --- a/plugins/provisioners/chef/config/chef_solo.rb +++ b/plugins/provisioners/chef/config/chef_solo.rb @@ -37,11 +37,14 @@ module VagrantPlugins @nfs || false end - def validate(env, errors) - super + def validate(machine) + errors = [] + errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \ + !cookbooks_path || [cookbooks_path].flatten.empty? + errors << I18n.t("vagrant.config.chef.run_list_empty") if \ + !run_list || run_list.empty? - errors.add(I18n.t("vagrant.config.chef.cookbooks_path_empty")) if !cookbooks_path || [cookbooks_path].flatten.empty? - errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if !run_list || run_list.empty? + { "chef solo provisioner" => errors } end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index c42e6492e..a5751cdc1 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -311,8 +311,6 @@ en: cookbooks_path_empty: "Must specify a cookbooks path for chef solo." run_list_empty: "Run list must not be empty." server_url_empty: "Chef server URL must be populated." - vagrant_as_json_key: |- - `vagrant` cannot be a JSON key, because it is used by Vagrant already. validation_key_path: "Validation key path must be valid path to your chef server validation key." ssh: private_key_missing: "`private_key_path` file must exist: %{path}"