Improve ansible provisioner error checks

This commit is contained in:
Collin Allen 2013-04-03 23:07:07 -07:00
parent a1ad1207bd
commit 5a052874b4
2 changed files with 23 additions and 2 deletions

View File

@ -35,12 +35,31 @@ module VagrantPlugins
def validate(machine)
errors = []
# Validate that a playbook path was provided
if !playbook
errors << I18n.t("vagrant.provisioners.ansible.no_playbook")
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 }
end
end
end
end
end

View File

@ -1017,7 +1017,9 @@ en:
upload_path_not_set: "`upload_path` must be set for the shell provisioner."
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:
base: