Hot answers tagged

164

This is a big question, so I'm going to break it up into three sections. Vagrant Vagrant is used to set up one or more virtual machines by: Importing pre-made images (called "boxes") Setting VM-specific settings (IP address, hostnames, port forwarding, memory, etc.) Running provisioning software like Puppet or Chef Note that it doesn't install software ...


90

Yes. In the Vagrantfile: Vagrant.configure('2') do |config| config.vm.synced_folder '.', '/vagrant', disabled: true # ... end


49

For every command in vagrant you can add the --debug flag. You can also set the VAGRANT_LOG env variable instead. For example: $ VAGRANT_LOG=info vagrant up or: $ set VAGRANT_LOG=info $ vagrant up Read more about it at Vagrant Documentation page.


42

Create a new box from your existing vm: cd into the directory with your Vagrant file run vagrant package This will export a box file called package.box by default run vagrant box add foo package.box to add package.box to your existing boxes. (Assuming you are using VirtualBox and not VMWare) run vagrant box list to verify it was added. Now you can just ...


37

I managed to solve this problem this morning. Here are the steps I took in case anyone else encounters this problem: Download a bootable linux .iso. I am running Ubuntu 14.04 x64 in my VM, so I decided to download the 64-bit Ubuntu 14.04 installation .iso from here. It shouldn't really matter what release you download, as long as it supports your file ...


33

At least two plugins which should help: vagrant-host-shell vagrant-triggers If you don't care that the script is run on (almost) all vagrant commands, you can also just shell out (or use what ever ruby magic) in Vagrantfile: system('./myscript.sh') Vagrant.configure('2') do |config| # ... end


31

Simple (and complete) Solution (I say complete because the accepted answer does not check if the user is using vagrant up. Therefore, the script is executed on each command, which is not what the OP wants.) There is however a simple solution to this. ARGV[0] is the first argument of the command entered and can be up, down, status, etc.. Simply check the ...


30

For vagrant users, add the following to your Vagrant file: config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--nictype1", "virtio"] end I got a speed boost of ~15x. On VirtualBox GUI I see now a different Adapter Type for my NAT interface: Paravirtualized Network (virtio-net).


29

In addition to the excellent answer given by Adam, Vagrant ties everything all together. Although Chef and Puppet (and Salt and shell scripts and whatever other provisioner you want to use) are separate things, Vagrant ties it all together and makes it work with just a vagrant up. That one command will just start the VM if that's all that is needed, ...


29

Assuming the run command stays running on the foreground, you can most probably end it with CTRL+C. Then the shell (and SSH) session can be terminated with exit or CTRL+D.


29

The official Download Vagrant webpage has all the available downloads for the latest version of Vagrant (2.0.1). Please download the proper package for your operating system (Linux deb) and architecture (32-bit or 64-bit OS). You can find SHA256 checksums for packages here. Download the .deb file and double-click it to open it for installation in the ...


27

eth0 as NAT is a fundamental requirement of Vagrant in its current state. But you can override the default router configuration for eth1. From the Vagrant docs: Default Router Depending on your setup, you may wish to manually override the default router configuration. This is required if you need access the Vagrant box from other networks over the public ...


26

I think I have found an answer. config.vm.provider "virtualbox" do |vb| config.vm.network "private_network", :type => 'dhcp', :name => 'vboxnet0', :adapter => 2 end This will create a host-only adapter as I wanted in my question


26

Only way I could do it is by killing the process: ps aux | grep VBox Then, select the appropiate vm process pid and: kill $pid


22

If you don’t want to have to update manually, I’ve created a repository which provides the latest packages from HashiCorp Vagrant in a PPA format. To use it, you’ll need to add the repository to your Ubuntu repository sources like this: sudo bash -c 'echo deb https://vagrant-deb.linestarve.com/ any main > /etc/apt/sources.list.d/wolfgang42-vagrant.list' ...


21

Because your ISP is hijacking your DNS queries. They are trying to be "helpful" by redirecting requests for nonexistent domains to a white label service that provides search results and advertising, from which everyone but you gets a cut of the revenue. Fortunately they do have a preferences page where you can supposedly turn it off.


21

1) open /root/.profile 2) remove the offensive line 3) replace it with: tty -s && mesg n Happy linuxing and a merry new year. George Hart, LSU


19

After reading your question again, It seems you're trying to do something a little different than I am - but I think our end goal is the same. I don't want to utilize the Vagrant Cloud service for hosting my base boxes, but I want to be able to distribute a development environment to my dev team, and utilize the features of the metadata.json file to ...


17

You can't just access a Vagrant box with its IP address from the host system. Vagrant's networking is meant to define an abstraction layer that works across multiple providers. The easiest way to access services on your Vagrant box is to configure port forwarding. In your Vagrantfile, see the section Vagrant.configure and set values for config.vm.network :...


17

I have found mach simpler solution for me Host ubuntu 14.04 guest ubuntu 14.04 Nat with port forwarding extremely slow upload speed from guest. It was so slow that speed test even cant measure that. I just switched to PCNet-Fast III adapter. And speed become good enough for me (40 Mb/s)


14

Simply add this line to your vagrant file Vagrantfile # Enable Dynamic Swap Space to prevent Out of Memory crashes config.vm.provision "shell", inline: "sudo apt install swapspace -y" And then reprovision vagrant up --provision How it works This is a dynamic swap space daemon. There are several, but here is a popular one. sudo apt install swapspace ...


14

It looks like this is caused by an interaction between the default vagrant configuration of config.ssh.shell to be bash -l (which simulates a login shell, thus processing login-related configuration files such as .profile) with a line in the /root/.profile file on at least some distributions of Linux (including, e.g., the one in the ubuntu/xenial64 vagrant ...


13

If you are using Virtualbox as your VM provider, I've successfully used this snippet to enable the use of a host VPN connection on a guest VM. config.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] end You may have seen the following code snippet online which no longer works on newer versions of Vagrant: ...


13

After extensive research and experimentation it appears that Vagrant was assigning each VM to a different submask, hence them not being able to connect to each other. In effect, they were all on different networks. It turns out you can, however, override this. To do so, simply configure the netmask for one as shown below. # -*- mode: ruby -*- # vi: set ...


12

Put this near the top of your Vagrantfile: module LocalCommand class Config < Vagrant.plugin("2", :config) attr_accessor :command end class Plugin < Vagrant.plugin("2") name "local_shell" config(:local_shell, :provisioner) do Config end provisioner(:local_shell) do ...


12

The Vagrantfile script of Homestead attempts (by calling scripts/homestead.rb script) to create a machine with a default name of 'homestead-7'. That's why it fails, if a box with that name already exists. You have 2 ways to solve this: Open Oracle VirtualBox and rename the existing machine (through its settings) from 'homestead-7' to any other name, and ...


11

(Sorry, quite naive about vagrant/virtualbox so forgive the lack of proper networking terminology) Your choice of bridge: en4) Thunderbolt is most likely the issue. Here's what I assume you want/need, rather than what you asked for: SSH login capability for vagrant to control your vm, from your dev box (the host). That's what the NAT with port ...


11

In Windows it's a bit messy. What you want to do is to use VBoxManage.exe list bridgedifs to list the possible bridge interface names (the actual names are device names, not connection names which you see in ipconfig output) VBoxManage is probably not in your %PATH% but you can find it in Virtualbox's dir. You also can just copy the device name from ...


11

Yes: # By default, Vagrant 1.7+ automatically inserts a different # insecure keypair for each new VM created. The easiest way # to use the same keypair for all the machines is to disable # this feature and rely on the legacy insecure key. config.ssh.insert_key = false For instance... My current "quickie testing" Vagrantfile looks like: C:\Users\...


11

I managed to change the log file location as per this post. To change the log file location to a folder called /temp relative to my Vagrantfile, I added this to the Vagrantfile (inside the Vagrant.configure(2) do |config| - section): config.vm.provider "virtualbox" do |vb| vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "...


Only top voted, non community-wiki answers of a minimum length are eligible