diff --git a/plugins/provisioners/ansible/config.rb b/plugins/provisioners/ansible/config.rb index de01835cd..c0d072855 100644 --- a/plugins/provisioners/ansible/config.rb +++ b/plugins/provisioners/ansible/config.rb @@ -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 \ No newline at end of file diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 307da6ce8..54041273b 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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: