Improve ansible provisioner error checks
This commit is contained in:
parent
a1ad1207bd
commit
5a052874b4
|
@ -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
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue