Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant provision live output

Tags:

Is there a way to get Vagrant to display the output of the provisioning tool as it runs, rather than just at the end? I'm using the Ansible plugin if that matters.

Vagrant appears to run the entire config.vm.provision section collecting the output, only displaying it once everything has completed.

This causes problems such as when a step in the process hangs or when you want to have interactive steps that involve the user.

like image 444
Damian Moore Avatar asked Sep 22 '13 14:09

Damian Moore


People also ask

What does Vagrant provision mean?

Command: vagrant provision [vm-name]Runs any configured provisioners against the running Vagrant managed machine. This command is a great way to quickly test any provisioners, and is especially useful for incremental development of shell scripts, Chef cookbooks, or Puppet modules.

When should I use Vagrant provision?

On the first vagrant up that creates the environment, provisioning is run. If the environment was already created and the up is just resuming a machine or booting it up, they will not run unless the --provision flag is explicitly provided. When vagrant provision is used on a running environment.

What is the provision that used in Vagrant by default?

The provision line configures Vagrant to use the shell provisioner to set up the machine with the bootstrap.sh file. The file path is relative to the location of the project root which should be the location of the Vagrantfile.


1 Answers

You may want to change vagrant logging level to debug so as to see more output when it does the provision => VAGRANT_LOG=debug vagrant up --provision

This works for Chef Solo (I haven't tried Vagrant with Ansible), the output for the provisioning part is similar to running chef-solo with debug (-l debug) log level.

Update added below

For Ansible provisioner, the following been added since vagrant 1.3.2:

  • provisioners/ansible: Support more verbosity levels, better documentation. [GH-2153].

See pull request 2153 for details, looks like the official doc has NOT been updated yet.

I think you should be able to add ansible.verbosity in the Vagrantfile to enable maximum verbosity level

Vagrant.configure("2") do |config|
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "provisioning/playbook.yml"
    ansible.verbose = "true"
    ansible.verbosity = "-vvv"
  end
end
like image 110
Terry Wang Avatar answered Dec 16 '22 22:12

Terry Wang