I want to sync my OSX dev folder which contains my applications to my VM. My VagrantFile (based off Phansible):
Vagrant.require_version ">= 1.5"
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |v|
v.name = "default"
v.customize [
"modifyvm", :id,
"--name", "default",
"--memory", 512,
"--natdnshostresolver1", "on",
"--cpus", 1,
]
end
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "192.168.33.99"
config.ssh.forward_agent = true
if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "default"
}
end
else
config.vm.provision :shell, path: "ansible/windows.sh", args: ["default"]
end
config.vm.synced_folder "/Users/xylar/Code", "/vagrant", type: "nfs"
end
When I vagrant up:
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
==> default: Running provisioner: ansible...
There are no error messages and when I vagrant ssh and view contents of the vagrant folder I only see some dot files (ansible, bash etc). Is there something I have missed?
I was being foolish. Once I had ssh'd into the box I thought I was in the synced folder (as it was called vagrant) however I was in /home/vagrant and the synced location was in /vagrant.
You need to specify the mount options:
config.vm.synced_folder "/Users/xylar/Code", "/vagrant", "nfs" => { :mount_options => ['dmode=777', 'fmode=777'] }
Related
Initially, I had 8 vagrant machines running and something went wrong. So I deleted the vms in ~/VirtualBox\ VMs folder and placed the backup .vmdk files in the same location.
Then I tried running vagrant up...
But I'm getting the following error
Bringing machine 'virtual-am1' up with 'virtualbox' provider...
==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
virtual-am1: Adapter 1: nat
virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--name", "virtual-am1"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]
Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp
>Please fix this customization and try again.
This is how my Vagrantfile looks like...
We had a custom Vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
config.vm.box = "centos653"
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
# config.vm.provision :shell, path: "bootstrap.sh"
nodes_config.each do |node|
node_name = node[0] # name of node
node_values = node[1] # content of node
config.vm.define node_name do |config|
# configures all forwarding ports in JSON array
ports = node_values['ports']
ports.each do |port|
config.vm.network :forwarded_port,
host: port[':host'],
guest: port[':guest'],
id: port[':id']
end
config.vm.synced_folder "/bits", "/vagrant/bits"
config.vm.synced_folder "../virtual", "/vagrant/virtual"
config.vm.hostname = node_values[':hostname']
#config.vm.network :private_network, ip: node_values[':ip']
config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_values[':node']]
vb.customize ["modifyvm", :id, "--cpus", 8]
end
end
end
end
This is how my nodes.json file looks like
{
"nodes": {
"virtual-am1": {
":node": "virtual-am1",
":ip": "192.168.1.50",
":hostname": "am1.onefederation.org",
"ports": [
{
":host": 2203,
":guest": 22,
":id": "ssh"
}
],
":memory": 1024
},
}
}
Please help!!!
I've had this error and you can use this fix:
Delete folder project in vagrant
rm -rf /home/protobox/VirtualBox VMs/project_folder
Go to project folder:
cd /var/www/project_folder
Then restart vagrant:
vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload
Finally you start vagrant
vagrant up
vagrant ssh
Or you can refer to here: http://getprotobox.com/docs/issues/vbox_rename
Good luck!
I am using scotch box, for starters but consider the following:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.25"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
# Optional NFS. Make sure to remove other synced_folder line too
# config.vm.synced_folder ".", "/var/www/", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
config.vm.provider "virtualbox" do |v|
v.memory = 1536
end
end
Now consider the following folder:
Now consider the following after doing vagrant up && vagrant ssh then cd /var/www:
vagrant#scotchbox:/var/www$ ls
vagrant#scotchbox:/var/www$
Where is public/ and html/? I have tried the nfs method and still nothing. Ideas?
can you try to do :
config.vm.synced_folder "./", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
or use an absolute path.
One of the reason is that . is already mapped to /vagrant on the VM. You can check in the output of vagrant up the shared folder that are mapped. so depending how vagrant is doing with the order of synced folder it can map its vagrant folder so the . will be mapped with /vagrant and not the /var/www
If the existing /vagrant is the issue and you're not using you can add
config.vm.synced_folder ".", "/vagrant", disabled: true
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.name = "web_vm"
v.customize ["modifyvm", :id, "--memory", "1024"]
#v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/web_vm", "1"]
end
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, host: 81, guest: 80, auto_correct: true
config.vm.network :forwarded_port, host: 6612, guest: 3306, auto_correct: true
config.vm.synced_folder "src/", "/var/www", owner: "vagrant", group: "vagrant", :mount_options => ["dmode=777,fmode=777"]
config.vm.provision :shell, path: "bootstrap.sh"
end
As you can see, The "src" folder is accessible in vagrant as "/var/www". However, there seem to be sync problems: I am trying to remove a folder which is shown empty where it is not when you cross-check with the Windows Explorer.
Any idea what is happening here?
I have the same issue, but it seemed to be resolved by increasing the max_user_watches - variable for inotify:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
My guess was that this had to to with the amount of files in the shared folder, and how vagrant has implemented the shared folder functionality.
I am trying to export a machine I created with vagrant to either an OVA file for Virtualbox or a package to host in vagrantcloud. The machine exports successfully, but then when I start it up, the directories which should have my files are empty. Seems like a vagrant noob question.
Why would "/usr/local/fieldpapers/" be empty when I start up my exported VM?
What can I do to keep files present in that directory after export?
Vagrant File:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.synced_folder "./", "/usr/local/fieldpapers/", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
mount_options: ["dmode=775,fmode=664"]
config.vm.provider :virtualbox do |vb, override|
vb.memory = 1024
vb.cpus = 1
vb.name = "Field Papers"
override.vm.box = "precise64"
override.vm.box_url = "http://files.vagrantup.com/precise64.box"
override.vm.network :private_network, ip: "192.168.33.10"
override.vm.provision :ansible, :playbook => "provisioning/playbook.yml"
end
end
First check your vagrant version, if it is latest.
Second, delete below line, vagrant will automatically mount your local folder to remote vagrant instance at /vagrant.
config.vm.synced_folder "./", "/usr/local/fieldpapers/", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
mount_options: ["dmode=775,fmode=664"]
I am pretty new using Vagrant and Chef. I am trying to change the Hostname of my Vagrant image using Chef. For some reason, I do not see a changed Hostname when I do vagrant ssh
What am I missing?
Here is my Cheffile
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'hostname'
Here is my Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
# config.vm.network :forwarded_port, guest: 3000, host: 3000
# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "hostname"
# Install Ruby 2.1.2 and Bundler
# Set an empty root password for MySQL to make things simple
chef.json = {
hostname: {
set_fqdn: 'Olympus'
}
}
end
end
As defined in the documentation you should set the attribute at the node level, not in node['hostname'].
In your case it will be
chef.json = {
set_fqdn: 'Olympus'
}
You can find more information in The hostname documentation