diff --git a/CHANGELOG.md b/CHANGELOG.md index 2055ce001..dc6ac2a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ IMPROVEMENTS: functionality removed in 1.1 from "config.dotfile_name" [GH-1524] - Vagrant will show an error if VirtualBox 4.2.14 is running. - Added provider to BoxNotFound error message. [GH-1692] + - If Ansible fails to run properly, show an error message. [GH-1699] BUG FIXES: diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 0999a820f..2d409a17f 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -87,6 +87,10 @@ module Vagrant error_key(:active_machine_with_different_provider) end + class AnsibleFailed < VagrantError + error_key(:ansible_failed) + end + class AnsiblePlaybookAppNotFound < VagrantError error_key(:ansible_playbook_app_not_found) end diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index aeafd86a9..1142b57cc 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -31,11 +31,13 @@ module VagrantPlugins } begin - Vagrant::Util::Subprocess.execute(*command) do |type, data| + exit_status = Vagrant::Util::Subprocess.execute(*command) do |type, data| if type == :stdout || type == :stderr @machine.env.ui.info(data, :new_line => false, :prefix => false) end end + + raise Vagrant::Errors::AnsibleFailed if exit_status != 0 rescue Vagrant::Util::Subprocess::LaunchError raise Vagrant::Errors::AnsiblePlaybookAppNotFound end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index df79cf17c..29252e576 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -106,6 +106,9 @@ en: Machine name: %{name} Active provider: %{active_provider} Requested provider: %{requested_provider} + ansible_failed: |- + Ansible failed to complete successfully. Any error output should be + visible above. Please fix these errors and try again. ansible_playbook_app_not_found: |- The "ansible-playbook" program could not be found! Please verify that "ansible-playbook" is available on the PATH of your host