Update Chef provisioner to new validation API
This commit is contained in:
parent
df32c47780
commit
fff021e51d
|
@ -90,12 +90,10 @@ module Vagrant
|
||||||
# Called after the configuration is finalized and loaded to validate
|
# Called after the configuration is finalized and loaded to validate
|
||||||
# this object.
|
# this object.
|
||||||
#
|
#
|
||||||
# @param [Environment] env Vagrant::Environment object of the
|
# @param [Machine] machine Access to the machine that is being
|
||||||
# environment that this configuration has been loaded into. This
|
# validated.
|
||||||
# gives you convenient access to things like the the root path
|
# @return [Hash]
|
||||||
# and so on.
|
def validate(machine)
|
||||||
# @param [ErrorRecorder] errors
|
|
||||||
def validate(env, errors)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,12 +52,6 @@ module VagrantPlugins
|
||||||
run_list << name
|
run_list << name
|
||||||
end
|
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
|
def instance_variables_hash
|
||||||
# Overridden so that the 'json' key could be removed, since its just
|
# Overridden so that the 'json' key could be removed, since its just
|
||||||
# merged into the config anyways
|
# merged into the config anyways
|
||||||
|
|
|
@ -22,12 +22,16 @@ module VagrantPlugins
|
||||||
def file_backup_path; @file_backup_path || "/srv/chef/cache"; end
|
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 encrypted_data_bag_secret; @encrypted_data_bag_secret || "/tmp/encrypted_data_bag_secret"; end
|
||||||
|
|
||||||
def validate(env, errors)
|
def validate(machine)
|
||||||
super
|
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 == ""
|
{ "chef client provisioner" => errors }
|
||||||
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?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,11 +37,14 @@ module VagrantPlugins
|
||||||
@nfs || false
|
@nfs || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(env, errors)
|
def validate(machine)
|
||||||
super
|
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?
|
{ "chef solo provisioner" => errors }
|
||||||
errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if !run_list || run_list.empty?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -311,8 +311,6 @@ en:
|
||||||
cookbooks_path_empty: "Must specify a cookbooks path for chef solo."
|
cookbooks_path_empty: "Must specify a cookbooks path for chef solo."
|
||||||
run_list_empty: "Run list must not be empty."
|
run_list_empty: "Run list must not be empty."
|
||||||
server_url_empty: "Chef server URL must be populated."
|
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."
|
validation_key_path: "Validation key path must be valid path to your chef server validation key."
|
||||||
ssh:
|
ssh:
|
||||||
private_key_missing: "`private_key_path` file must exist: %{path}"
|
private_key_missing: "`private_key_path` file must exist: %{path}"
|
||||||
|
|
Loading…
Reference in New Issue