hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.43k forks source link

Ansible provisioner behavior on failure during vagrant up #9665

Closed binaryronin closed 6 years ago

binaryronin commented 6 years ago

I am using Vagrant to test development of Ansible playbooks before moving them into production. I updated Vagrant to the current version and the behavior on the failure of a playbook has changed, but only during a vagrant up. Now when a playbook fails during a vagrant up, Vagrant spits out an entire Ruby Traceback. This is messy and unnecessary when the failure is simply with Ansible playbooks and not Vagrant.

1) Is there anyway to disable this behavior? The traceback says "report_on_exception is true" but I see no documentation or threads on how to set to false (if this would even solve the issue) 2) I don't feel this should be the default behavior. Especially since vagrant provision only shows the Ansible failure (which is much cleaner) 3) Why the difference between vagrant up and vagrant provision?

Vagrant version

Vagrant 2.0.3

Host operating system

Linux bebop 4.15.15-1-ARCH #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018 x86_64 GNU/Linux

Guest operating system

Any

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.provider "virtualbox" do |vb|
    vb.cpus = 1
    vb.memory = 1024
  end

  config.vm.provision "ansible" do |ansible|
    ansible.groups = {
      "common" => ["centos", "debian8"]
    }

    ansible.playbook = "site.yml"
    ansible.become = true
    ansible.become_user = "root"
    ansible.compatibility_mode = "2.0"
  end

  # Use the following if you want to run multiple machines
  config.vm.define "centos" do |centos|
    centos.vm.box = "centos/7"
  end

  config.vm.define "debian8" do |debian8|
    debian8.vm.box = "debian/jessie64"
  end

end

Expected behavior

As in previous versions of Vagrant, I should see the Ansible failure only and not a full trace of Ruby debugging when running vagrant up

Actual behavior

I get an entire Ruby debugging trace.

Steps to reproduce

  1. Set up Vagrantfile
  2. Have failing Ansible playbook
  3. run vagrant up
gildegoma commented 6 years ago

@binaryronin I tried to reproduce this issue with Vagrant 2.1 (2.1.0 and 2.1.1), where actually both up and provision behave the same, and as expected:

Could you please upgrade and check if you still face this problem. Many thanks in advance!

binaryronin commented 6 years ago

@gildegoma After upgrading to Vagrant 2.1.1 this has been fixed, no more Ruby stack trace.

Thank you!!

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.