hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.26k stars 4.43k forks source link

vagrant on WSL - multiple folders under ~/VirtualBox VMs #9776

Open vadbes46 opened 6 years ago

vadbes46 commented 6 years ago

After updating from 2.0.3 vagrant creates multiple folders when creating only one VM: The first folder has the name of a box and inside there is *.vmdk (virtual disk) with the same name The second contains all VMs staff

Suppose that during vagrant up when the box has been imported it should be placed inside a folder with all VMs things, but remains standalone Nevertheless everything is working fine because .vbox points to correct locations.

Vagrant version

Vagrant 2.1.0

Host operating system

WSL

Guest operating system

ubuntu server 16, CenOs7

Vagrantfile

no matter of my vagrant file contents, no matter what box to use

Expected behavior

The vm should have all its files inside one folder

vadbes46 commented 6 years ago

to be more clear let me show the directory structure of 2 individual VMs qip shot - screen 022

and those VMs running: qip shot - screen 021

chrisroberts commented 6 years ago

What version of virtualbox are you using, and did you recently upgrade virtualbox?

chrisroberts commented 6 years ago

Would you also please provide a minimal version of the Vagrantfile you are using which produces this result. Thanks!

vadbes46 commented 6 years ago

Thanks for quick reply

This is 5.2.10 clean install, tried on several machines There is no problem with vagrant shipped for Windows (.exe), only for vagrant in WSL (I mean .deb)

Some time later will provide vagrant file

Thanks & Regards, Vadim

vadbes46 commented 6 years ago

Here is an example:

# install plugins
need_restart = false
required_plugins = %w(vagrant-vbguest nugrant vagrant-cachier vagrant-hostmanager vagrant-disksize vagrant-bindfs)
required_plugins.each do |plugin|
  unless Vagrant.has_plugin? plugin
    system "vagrant plugin install #{plugin}"
    need_restart = true
  end
end
exec "vagrant #{ARGV.join' '}" if need_restart

# configure VM
Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  config.ssh.private_key_path = ["~/.vagrant.d/insecure_private_key"]
  # config.ssh.username = "vagrant"
  # config.ssh.password = "vagrant"

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.manage_guest = true
  config.hostmanager.ignore_private_ip = false
  config.hostmanager.include_offline = false

  config.vm.box = "centos/7"
  config.vm.box_check_update = true
  config.vbguest.auto_reboot = true

  config.vm.provider "virtualbox" do |v|
    v.gui = false
    # v.memory = config.user.env.memory
    # v.cpus = config.user.env.cpus
    v.customize ['modifyvm', :id, '--vram', 128]
    v.customize ['modifyvm', :id, '--acpi', 'on']
    v.customize ['modifyvm', :id, '--ioapic', 'on']
    v.customize ['modifyvm', :id, '--vrde', 'off']
    v.customize ['modifyvm', :id, '--audio', 'none']
    v.customize ['modifyvm', :id, '--paravirtprovider', 'kvm']
    v.customize ["modifyvm", :id, '--natdnsproxy1', 'on']
    v.customize ["modifyvm", :id, '--natdnshostresolver1', 'on']
    v.customize ['modifyvm', :id, '--nictype1', 'virtio']
  end

  config.vm.define 'centos' do |node|
    node.vm.hostname = 'ansible-centos'
    node.vm.network "private_network", nic_type: 'virtio', ip: "192.168.13.13"

    node.vm.synced_folder "./", "/vagrant", disabled: true # disable default mapping
    node.vm.synced_folder "./", "/data/ansible-centos", create: true

    node.vm.provision "shell", inline: <<-SHELL
      #!/usr/bin/env bash
      if [ ! -d /etc/ansible/facts.d ]; then
        yum install epel-release ansible wget -y &>/dev/null
        yum repolist &>/dev/null
        yum update -y &>/dev/null
      fi
      wget --no-check-certificate 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys 2>/dev/null
      chmod 600 /home/vagrant/.ssh/authorized_keys
      chown -R vagrant:vagrant /home/vagrant/.ssh
      if [ ! -e /vagrant ]; then
        ln -s /data/ansible-centos /vagrant;
      fi
      sudo sed -i "s/.*host_key_checking.*/host_key_checking = False/g" /etc/ansible/ansible.cfg
    SHELL

    # limit = "dev"
    # tags = "vagrant_dev"

    # provisioner = :ansible_local
    # node.vm.provision provisioner do |ansible|
    #   ansible.inventory_path = "/data/ansible-centos/provision/hosts"
    #   ansible.playbook = "/data/ansible-centos/provision/site.yml"
    #   ansible.limit = limit
    #   ansible.compatibility_mode = "2.0"
    #   ansible.tags = tags
    #   #ansible.verbose = "vvv"
    # end

  end
end
vadbes46 commented 6 years ago

BTW, after last vagrant update I leave only those env vars:

export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export VAGRANT_HOME="/home/vadbes46/.vagrant.d"

and vbox is installed directly in Windows (not .deb)