So I've been looking around a little bit for this issue, but maybe I lack something.
I freshly generated a Vagrant VM (With VirtualBox) but the files only seem to sync 1 time when the server loads/reloads.
I only have this in my configuration file, am I missing something here?
Vagrant.configure("2") do |config|
config.vm.box = "debian/stretch64"
config.vm.network "forwarded_port", guest: 25565, host: 25565
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
end
end
I also tried with
config.vm.synced_folder ".", "/vagrant_files"
But that doesn't seem to change anything.
I don't have any errors on load, but the result is that when I add a file on the server, I don't see it in the project folder on my pc
Related
I have used the vagrantfile provided in this here tutorial and can't seem to get my local files synced to the VM. I tried mkdir vagrant_data and that didn't show them in there. What do I do?
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder "./", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "2048"
end
I believe you may be giving the wrong file path of the host machine. Instead of giving the ./ relative path which could refer to anything. Try using the absolute path instead. Here if the Official tutorial on how to configure.
I've recently checked out a project that hasn't been touched in 8 months.
On vagrant up-ing I'm finding that any connections made to the guest are ridiculously slow, for example 12 database CRUD operations are taking five minutes to execute against the database on the guest (and it's not the database operations taking the time).
I'm finding though if I ping stackoverflow from both the Windows host and the guest they're returning very similar times back.
Annoyingly there's been quite a few changes since I was last able to get this working due to the previous vagrant box not working. Changes are as follows:
Changing of the actual vagrant box from centos[6.5] to Centos/6
introduction of --natdnshostresolver1 and --natdnsproxy1 (to try fix this problem)
Addition of config.vm.synced_folder ".", "/vagrant", type: "virtualbox" (required or the vagrant up failed)
My vagrantfile is as follows:
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.hostname = "DEV"
config.vm.provision "shell" do |s|
s.path = "build.sh"
s.args = ["development"]
end
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
config.vm.synced_folder "../releases", "/mnt/releases"
config.vm.synced_folder "../sites", "/mnt/releases/sites"
config.vm.synced_folder "../environment/components", "/mnt/components"
config.vm.synced_folder "../environment/scripts", "/mnt/scripts"
config.vm.synced_folder "../core", "/mnt/releases/core"
config.vm.synced_folder "../controller", "/mnt/releases/controller"
config.vm.network :forwarded_port, guest: 80, host: 8000
config.vm.network :forwarded_port, guest: 3306, host: 3306
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.network :forwarded_port, guest: 22000, host: 22000
end
Vagrant version is 1.9.2 (downgraded from 1.9.3 and 1.9.4)
Virtual box version is 5.1.18
So after lots and lots of searching it appears the problem is with VirtualBox rather than Vagrant.
I came across many posts which say adjust the nictype in the vagrant file like such. This is to adjust the virtual networking hardware provided by virtualbox.
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--nictype1", "82540EM"]
end
Other suggestions were virtio and AMD, this feature and settings can be read in the official documentation here: https://www.virtualbox.org/manual/ch06.html.
However
This barely did anything for me if I'm honest.
After more digging I came across this article How to speed up virtual machines in VirtualBox enormously with a simple tweak which simply put 'switch power plans to boost performance'. I was skeptical, but I run a laptop on powersaver so i'd thought I might as well give it a go. It genuinely solved the problem.
I am working on to setup the vagrant environment on the mac. I have done the following steps.
Installed the virtualbox
Clone my project to local disk
Downloaded the box and added the box successfully
I have also edit the vagrant file and add the name of box to the vagrant file.
Now when i run the command "vagrant provision" this error occurs
default: VM not created. Moving on...
I have google it a lot but no idea that what to do.
sudo vagrant box list
Result:
bpc_box (virtualbox, 0)
new_box (virtualbox, 0)
Vagrant file
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bpc_box"
config.vm.synced_folder "workspace/", "/vagrant"
config.vm.network "forwarded_port", guest: 8080, host: 8085
config.vm.network "forwarded_port", guest: 80, host: 8090
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = 2048
end
config.vm.provider "parallels" do |prl|
prl.cpus = 2
prl.memory = 2048
end
config.ssh.forward_agent = true
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/main.yml"
end
end
You need to spin the VM first, the first command to run is
$ vagrant up
this will bring your VM up and provision it if this is the first time this particular VM has been started.
once the VM is up and running you can run vagrant provision to force the (re)provisioning of the running VM.
You can read more about vagrant cli option at https://www.vagrantup.com/docs/cli/
I have the following vagrant VM:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "forwarded_port", guest: 8000, host: 8080
config.vm.network "forwarded_port", guest: 8001, host: 8081
config.vm.synced_folder "../..", "/home/edgleweb"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4000"
vb.cpus = 2
end
config.vm.provision "shell", path: "./provisioner.sh", args: "edgleweb" #, run: "always"
end
I am having some issues with my VM which I use for development. I would like to spin another exact copy of it after a box update. I don't want to copy and paste the folder as that is against DRY principle. Vagrant documentation calls for a multi-machine setup as follows:
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: "echo Hello"
config.vm.define "web" do |web|
web.vm.box = "apache"
end
config.vm.define "db" do |db|
db.vm.box = "mysql"
end
end
But I do want to keep my initial VM intact until I fully test the new one. I don't want to lose it. It is not apparent from the documentation how I keep it. How do I keep it?
You could use the vagrant snapshot command with either the save or push sub-commands to achieve this. See the documentation here.
I am using Vagrant to house my Rails application. Unfortunately I am hitting a blocker in that using NFS to mount my synced folder results in errors with anything reading from or writing to the synced folder; Resque, Solr and even bundler.
Using bundle install --path vendor/bundle, for instance, results in:
Bundler::GemspecError: Could not read gem at /var/applications/beatroot/vendor/bundle/ruby/2.1.0/cache/sunspot_rails-2.1.1.gem. It may be corrupted.
Reverting to using a non-NFS synced_folder resolves the issue, leading me to believe it's a permissions problem. Unfortunately the performance loss necessitates using NFS.
Has anyone else encountered this? Is there a solution?
The host is OS X 10.9.2 and the guest is Ubuntu Precise 64.
My vagrant file looks like this:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provider :virtualbox do |virtualbox|
virtualbox.name = "beatroot-development"
virtualbox.memory = 3072
virtualbox.cpus = 4
end
# Provision dependencies from shell
config.vm.provision :sprinkle do |sprinkle|
sprinkle.script = "provisioning/bootstrap_vagrant.rb"
sprinkle.cloud = true
sprinkle.verbose = true
end
# Forward port to Unicorn
config.vm.network :forwarded_port, host: 5009, guest: 5009
# Create a private network to allow for NFS mounting
config.vm.network :private_network, ip: "192.168.50.50"
# Mount our app in the VM
# We use NFS for performance gain
config.vm.synced_folder "./", "/var/applications/beatroot", nfs: true
end