hashicorp / vagrant

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

Can't visit sites on my host after updating of Virtualbox. #7169

Closed berpcor closed 8 years ago

berpcor commented 8 years ago

Everything worked excelent. Had a problem with long names of files in shared folder created by npm. (I needed to install gulp). Installed the latest version of virtualbox (Vagrant version was 1.7.x). After that vagrant up stopped working (Virtualbox's error - E_FAIL (0x80004005) Failed to create the host-only adapter). Then I reinstalled Virtualbox - didn't help. Then I deleted virtualbox at all. For some reasons all of my network adapters were deleted too (ethernet and wireless) - there were deleted drivers. I deleted them from the list of hardware, updated my configuration and reinstalled drivers. Then I installed Virtualbox 5 (latest for now). Vagrant up now is working (it looks like that), but when I type in some of my sites in address bar, I can't visit it - timeout. Upd.: I watched logs There was

The guest additions on this VM do not match the installed version of
    Vaprobash: VirtualBox! In most cases this is fine, but in rare cases it can
    Vaprobash: prevent things such as shared folders from working properly. If you see
    Vaprobash: shared folder errors, please make sure the guest additions within the
    Vaprobash: virtual machine match the version of VirtualBox you have installed on
    Vaprobash: your host and reload your VM.
    Vaprobash: 
    Vaprobash: Guest Additions Version: 4.3.10
    Vaprobash: VirtualBox Version: 5.0

I installed https://github.com/dotless-de/vagrant-vbguest Additions updated, but I still can't enter my site via browser.

Vagrant version

Installed Version: 1.8.1 Latest Version: 1.8.1

Host operating system

"Ubuntu 14.04.3 LTS"

Guest operating system

Windows 7

Vagrantfile


# -*- mode: ruby -*-
# vi: set ft=ruby :

# Config Github Settings
github_username = "fideloper"
github_repo     = "Vaprobash"
github_branch   = "1.4.1"
github_url      = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"

# Because this:https://developer.github.com/changes/2014-12-08-removing-authorizations-token/
# https://github.com/settings/tokens
github_pat          = ""

# Server Configuration

hostname        = "vaprobash.dev"

# Set a local private network IP address.
# See http://en.wikipedia.org/wiki/Private_network for explanation
# You can use the following IP ranges:
#   10.0.0.1    - 10.255.255.254
#   172.16.0.1  - 172.31.255.254
#   192.168.0.1 - 192.168.255.254
server_ip             = "192.168.56.56"
server_cpus           = "1"   # Cores
server_memory         = "1024" # MB
server_swap           = "2048" # Options: false | int (MB) - Guideline: Between one or two times the server_memory

# UTC        for Universal Coordinated Time
# EST        for Eastern Standard Time
# US/Central for American Central
# US/Eastern for American Eastern
server_timezone  = "UTC"

# Database Configuration
mysql_root_password   = "root"   # We'll assume user "root"
mysql_version         = "5.5"    # Options: 5.5 | 5.6
mysql_enable_remote   = "false"  # remote access enabled when true
pgsql_root_password   = "root"   # We'll assume user "root"
mongo_version         = "2.6"    # Options: 2.6 | 3.0
mongo_enable_remote   = "false"  # remote access enabled when true

# Languages and Packages
php_timezone          = "UTC"    # http://php.net/manual/en/timezones.php
php_version           = "5.6"    # Options: 5.5 | 5.6
ruby_version          = "latest" # Choose what ruby version should be installed (will also be the default version)
ruby_gems             = [        # List any Ruby Gems that you want to install
  #"jekyll",
  #"sass",
  #"compass",
]

go_version            = "latest" # Example: go1.4 (latest equals the latest stable version)

# To install HHVM instead of PHP, set this to "true"
hhvm                  = "false"

# PHP Options
composer_packages     = [        # List any global Composer packages that you want to install
  #"phpunit/phpunit:4.0.*",
  #"codeception/codeception=*",
  #"phpspec/phpspec:2.0.*@dev",
  #"squizlabs/php_codesniffer:1.5.*",
]

# Default web server document root
# Symfony's public directory is assumed "web"
# Laravel's public directory is assumed "public"
public_folder         = "/var/www"

laravel_root_folder   = "/var/www/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists
laravel_version       = "latest-stable" # If you need a specific version of Laravel, set it here
symfony_root_folder   = "/var/www/symfony" # Where to install Symfony.

nodejs_version        = "latest"   # By default "latest" will equal the latest stable version
nodejs_packages       = [          # List any global NodeJS packages that you want to install
  #"grunt-cli",
  #"gulp",
  #"bower",
  #"yo",
]

# RabbitMQ settings
rabbitmq_user = "user"
rabbitmq_password = "password"

sphinxsearch_version  = "rel22" # rel20, rel21, rel22, beta, daily, stable

Vagrant.configure("2") do |config|

  # Set server to Ubuntu 14.04
  config.vm.box = "ubuntu/trusty64"

  config.vm.define "Vaprobash" do |vapro|
  end

  if Vagrant.has_plugin?("vagrant-hostmanager")
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.ignore_private_ip = false
    config.hostmanager.include_offline = false
  end

  # Create a hostname, don't forget to put it to the `hosts` file
  # This will point to the server's default virtual host
  # TO DO: Make this work with virtualhost along-side xip.io URL
  config.vm.hostname = hostname

  # Create a static IP
  config.vm.network :private_network, ip: server_ip
  config.vm.network :forwarded_port, guest: 80, host: 8000
  config.vm.network :forwarded_port, guest: 9200, host: 9200

  # Enable agent forwarding over SSH connections
  config.ssh.forward_agent = true

  # Use NFS for the shared folder
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.synced_folder "projects", "/var/www", create:true,
            id: "core",
            :nfs => true,
            :mount_options => ['nolock,vers=3,udp,noatime,actimeo=2']

  # Replicate local .gitconfig file if it exists
  if File.file?(File.expand_path("~/.gitconfig"))
    config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
  end

  # If using VirtualBox
  config.vm.provider :virtualbox do |vb|

    vb.name = hostname

    # Set server cpus
    vb.customize ["modifyvm", :id, "--cpus", server_cpus]

    # Set server memory
    vb.customize ["modifyvm", :id, "--memory", server_memory]

    # Set the timesync threshold to 10 seconds, instead of the default 20 minutes.
    # If the clock gets more than 15 minutes out of sync (due to your laptop going
    # to sleep for instance, then some 3rd party services will reject requests.
    vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]

  end

  # If using VMWare Fusion
  config.vm.provider "vmware_fusion" do |vb, override|
    override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"

    # Set server memory
    vb.vmx["memsize"] = server_memory

  end

  # If using Vagrant-Cachier
  # http://fgrehm.viewdocs.io/vagrant-cachier
  if Vagrant.has_plugin?("vagrant-cachier")
    # Configure cached packages to be shared between instances of the same base box.
    # Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage
    config.cache.scope = :box

    config.cache.synced_folder_opts = {
        type: :nfs,
        mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
    }
  end

  # Adding vagrant-digitalocean provider - https://github.com/smdahlen/vagrant-digitalocean
  # Needs to ensure that the vagrant plugin is installed
  config.vm.provider :digital_ocean do |provider, override|
    override.ssh.private_key_path = '~/.ssh/id_rsa'
    override.ssh.username = 'vagrant'
    override.vm.box = 'digital_ocean'
    override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"

    provider.token = 'YOUR TOKEN'
    provider.image = 'ubuntu-14-04-x64'
    provider.region = 'nyc2'
    provider.size = '512mb'
  end

  ####
  # Base Items
  ##########

  # Provision Base Packages
  config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone]

  # optimize base box
  config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true

  # Provision PHP
  config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [php_timezone, hhvm, php_version]

  # Provision Vim
  config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url

  ####
  # Web Servers
  ##########

  # Provision Apache Base
  config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url]

  ####
  # Databases
  ##########

  # Provision MySQL
  config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote]

  ####
  # In-Memory Stores
  ##########

  # Install Memcached
  config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh"

  # Provision Redis (without journaling and persistence)
  config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh"

  ####
  # Frameworks and Tooling
  ##########

  # Provision Composer
  # You may pass a github auth token as the first argument
  config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: [github_pat, composer_packages.join(" ")]

  # Install git-ftp
  config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false

end

Debug output

https://gist.github.com/berpcor/9f475bd8b0823d45d690 Upd.: https://gist.github.com/berpcor/d04b5bf6e36a51c5ad72 There was a big amount information in console but only this is stored in file.

Expected behavior

After vagrant up I should be able to visit my project ia adress bar. But I can't.

sethvargo commented 8 years ago

Hi @berpcor

Can you please run the command again like this:

vagrant up --debug &> vagrant.log

and then put the contents of vagrant.log in a gist?

berpcor commented 8 years ago

https://gist.github.com/berpcor/d04b5bf6e36a51c5ad72

sethvargo commented 8 years ago

Hey @berpcor

Unfortunately I don't have access to those installation scripts. I removed some of the comments and the plugins from your Vagrantfile - can you tell me if the issue persists with this Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.hostname = hostname

  config.vm.network :private_network, ip: server_ip
  config.vm.network :forwarded_port, guest: 80, host: 8000
  config.vm.network :forwarded_port, guest: 9200, host: 9200

  config.ssh.forward_agent = true

  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.synced_folder "projects", "/var/www", create:true,
            id: "core",
            :nfs => true,
            :mount_options => ['nolock,vers=3,udp,noatime,actimeo=2']

  config.vm.provider :virtualbox do |vb|
    vb.name = hostname
    vb.customize ["modifyvm", :id, "--cpus", server_cpus]
    vb.customize ["modifyvm", :id, "--memory", server_memory]
    vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
  end

  config.vm.provision "shell", path: "#{github_url}/scripts/base.sh", args: [github_url, server_swap, server_timezone]
  config.vm.provision "shell", path: "#{github_url}/scripts/base_box_optimizations.sh", privileged: true
  config.vm.provision "shell", path: "#{github_url}/scripts/php.sh", args: [php_timezone, hhvm, php_version]
  config.vm.provision "shell", path: "#{github_url}/scripts/vim.sh", args: github_url
  config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url]
  config.vm.provision "shell", path: "#{github_url}/scripts/mysql.sh", args: [mysql_root_password, mysql_version, mysql_enable_remote]
  config.vm.provision "shell", path: "#{github_url}/scripts/memcached.sh"
  config.vm.provision "shell", path: "#{github_url}/scripts/redis.sh"
  config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: [github_pat, composer_packages.join(" ")]
  config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false
end
berpcor commented 8 years ago

This vagrantfile doesn't work as github_url variable not set, for example. Should I create a new vagrantfile in a new directory with the content you provided?

sethvargo commented 8 years ago

Hi @berpcor

Sorry - you still need all the variables at the top (same as your original Vagrantfile). I just didn't post them there.

berpcor commented 8 years ago

I created a new folder c:\www3, put there vagrantfile you provided. Executed vagrant up first time I had freeze on mounting NFS shared folder. I pressed ctr+c, then manually stopped VM in Virtualbox. Started again vagrant up, now I am waiting for provisioning...

berpcor commented 8 years ago

Nope, the same problem... ((

sethvargo commented 8 years ago

Hi @berpcor

What port(s) are you trying to access and how?

berpcor commented 8 years ago

80 I guess... http://192.168.56.56.xip.io - like it worked before... Besides, now I have 17 VirtualBox Host-Only Network adapters )

sethvargo commented 8 years ago

Hi @berpcor

I'm not familiar with xip.io - what is that? Did you destroy the old Vagrant machines? Im not sure why you have so many host-only adapters.

berpcor commented 8 years ago

http://xip.io/ I won't describe better ) Just several sentences.

berpcor commented 8 years ago

I am checking settings in Virtualbox GUI. The last VM has no shared folders.

sethvargo commented 8 years ago

Hi @berpcor

Can you access the machine by IP address directly (no xip.io)? The last VM won't have shared folders (they are explicitly disabled, and if you put it in a subfolder, "projects" won't exist either).

berpcor commented 8 years ago

http://192.168.56.56 Can't get access too...

berpcor commented 8 years ago

Why I decided to use gulp?.. Main rule: don't touch if it works - was broken...

berpcor commented 8 years ago
config.vm.network :private_network, ip: "192.168.56.56"
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
config.vm.network :forwarded_port, guest: 9200, host: 9200

I have access to my guest on url localhost:8080, but I can't open IP-address.

berpcor commented 8 years ago

Exactly. Every time I reload vagrant it creates a new host-only Network.

sethvargo commented 8 years ago

Hi @berpcor

I just tried, and I'm unable to reproduce this issue on my machine. Just to make sure, your "host" (local laptop) is ubuntu 14.04 and the guest (vm you're trying to run) is windows 7? What box are you using?

berpcor commented 8 years ago

1-st question: yes and yes. config.vm.box = "ubuntu/trusty64"

berpcor commented 8 years ago

Again. localhost:8080 - working localhost:9200 (Elasticsearch) - working. Can't open IP address.

berpcor commented 8 years ago

config.vm.network :private_network, ip: "169.254.213.188" - my IP now. Vagrant created host-only network with IP of 169.254.55.176. Is it normal?

berpcor commented 8 years ago

From inside of the guest I can ping 169.254.213.188.

berpcor commented 8 years ago

If I set IP equals to 192.168.56.X Host-only Network adapter should get 192.168.56.1 Why in my case it is not true?

berpcor commented 8 years ago

I moved forward a little bit. When I start Vagrant, as I said, it should take my IP then search appropriate network adapter (the same network), if I haven't got it, vagrant should create it (IP equals to mine, but the last octet is 1). In my case each time I reloaded Vagrant, it created a new network adapter BUT not in the subnet in which my IP exists. I deleted all adapters, manually edited settings of the very first adapter (IP: 192.168.56.1, mask 255.255.255.0, IP of my guest machine was 192.168.56.56) then chosen it in GUI of Virtualbox settings for VM and everything works. Now I am trying to reproduce behaviour of Vagrant...

Vagrant is installed (latest version), Virtualbox (4.3.36, downgraded from 5) too. I'll try to delete all of virtual adapters and when I do vagrant up Vagrant should create adapter with necessary settings. I want to see what will happen.

berpcor commented 8 years ago

It looks like this - https://github.com/mitchellh/vagrant/issues/1014 - is my problem.

ZamanOof commented 8 years ago

Hi like i have the same issue this code when vagrant up with debug

Untitled.txt

regards

sethvargo commented 8 years ago

Hi @berpcor

I'm having a very difficult time following the issue you're describing. It seems your original reported issue has changed.

Can you do the following:

  1. Destroy all your Vagrant VMs
  2. Make sure you are running the latest version of Virtualbox
  3. Open the virtualbox GUI and delete any VMs
  4. Restart your computer
  5. Use the following Vagrantfile to bring up a machine
  6. Try to view http://33.33.33.10 in your browser
Vagrant.configure(2) do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.network "private_network", ip: "33.33.33.10"
  config.vm.provision "shell", inline: "sudo apt-get -yqq install apache2"
end

This is a vanilla Vagrantfile that installs apache 2. You should see a message like "it works" on the default page.

sethvargo commented 8 years ago

Hey there,

I am going to close this due to lack of response. If this is still occurring, please open a new issue and follow the provided issue template that appears when you click the "New Issue" button. This will help us in getting a reproduction and fix. Thanks! 😄