Improve ansible provisioner error checks
This commit is contained in:
parent
a1ad1207bd
commit
5a052874b4
|
@ -35,10 +35,29 @@ module VagrantPlugins
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
|
# Validate that a playbook path was provided
|
||||||
if !playbook
|
if !playbook
|
||||||
errors << I18n.t("vagrant.provisioners.ansible.no_playbook")
|
errors << I18n.t("vagrant.provisioners.ansible.no_playbook")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Validate the existence of said playbook on the host
|
||||||
|
if playbook
|
||||||
|
expanded_path = Pathname.new(playbook).expand_path(machine.env.root_path)
|
||||||
|
if !expanded_path.file?
|
||||||
|
errors << I18n.t("vagrant.provisioners.ansible.playbook_path_invalid",
|
||||||
|
:path => expanded_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Validate the existence of the inventory_file, if specified
|
||||||
|
if inventory_file
|
||||||
|
expanded_path = Pathname.new(inventory_file).expand_path(machine.env.root_path)
|
||||||
|
if !expanded_path.file?
|
||||||
|
errors << I18n.t("vagrant.provisioners.ansible.inventory_file_path_invalid",
|
||||||
|
:path => expanded_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
{ "ansible provisioner" => errors }
|
{ "ansible provisioner" => errors }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1017,7 +1017,9 @@ en:
|
||||||
upload_path_not_set: "`upload_path` must be set for the shell provisioner."
|
upload_path_not_set: "`upload_path` must be set for the shell provisioner."
|
||||||
|
|
||||||
ansible:
|
ansible:
|
||||||
no_playbook: "`playbook` must be set for the ansible provisioner."
|
no_playbook: "`playbook` must be set for the Ansible provisioner."
|
||||||
|
playbook_path_invalid: "`playbook` for the Ansible provisioner does not exist on the host system: %{path}"
|
||||||
|
inventory_file_path_invalid: "`inventory_file` for the Ansible provisioner does not exist on the host system: %{path}"
|
||||||
|
|
||||||
guest:
|
guest:
|
||||||
base:
|
base:
|
||||||
|
|
Loading…
Reference in New Issue