This time a few things which make life easier.
Check for Windows
There a quit some situations for Vagrant where you have platform specific steps to do. Here an example for Windows.
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # some content if Vagrant::Util::Platform.windows? then # do something Windows specific else # do something not Windows specific end end
Set a default provider
By default, VirtualBox is the default provider for Vagrant but sometimes it is needed to change.
# set provider via vagrant up command $ vagrant up --provider vmware_fusion
It is possible to use environment variables in Vagrantfile. So the 2nd option is to set provider inside Vagrantfile!
# -*- mode: ruby -*- # vi: set ft=ruby : ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion' Vagrant.configure("2") do |config| # some content end
Multiple Vagrantfiles in one directory
Sometimes it could happen that you have multiple Vagrantfiles in one directory. In such case environment variables helps.
# select specific Vagrantfile $ VAGRANT_VAGRANTFILE=Vagrantfile_01 vagrant up
Create log files
To enable detailed logging use the VAGRANT_LOG environmental variable.
# run with info log level (Linux and Mac OS) $ VAGRANT_LOG=info vagrant up # run with info log level (Windows) $ set VAGRANT_LOG=info $ vagrant up
Level names can be “debug”, “info”, “warn” and “error”.
Jenkins log without colored output
For Jenkins log, the color output is superfluous! Here an simple example:
pipeline { agent any stages { stage('Build') { steps { // Make the output without color vagrant up --no-color } } } }