precise64 for Hyper-V vs VirtualBox

32 views
Skip to first unread message

evand...@outlook.com

unread,
Aug 26, 2017, 5:47:02 PM8/26/17
to Vagrant
Hello Ninjas, I am new to Vagrant (and I am already liking it) and I've bumped into an interesting situation. I've upped hashicorp/precise64 with my provisioning script on top of macOS Sierra running VirtualBox and everything seems fine. I am able to run our PHP solution. But when I up the same box but now on top of Windows running Hyper-V (with the proper adjustments in the Vagrantfile - see both below) I get now errors in deploying it, no errors in provisioning it, but the application (PHP-based) fails to run with an Exception Handler error. 

Any ideas on how to start the debugging (mostly painful) session? I want to deploy this box onto Azure (I have received the box from another company that is leaving the task to us to maintaining it). 

Keep in mind that BOTH boxes get upped and provisioned WITHOUT ERRORS (at least none are shown) during the vagrant up

Vagrant File (macOS + VirtualBox)

require "yaml"
require "fileutils"

CONF = YAML.load(File.open(File.join(File.dirname(__FILE__), "provision/config.yml"), File::RDONLY).read)

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

  config.vm.box = "precise64"

  config.vm.hostname = CONF['vm']['name']
  config.vm.network "private_network", type: "dhcp"
  config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true

  config.vm.provider "virtualbox" do |vb|
    vb.name = CONF['vm']['name']
    vb.customize ["modifyvm", :id, "--memory", CONF['vm']['memory']]
  end

  config.vm.define CONF['vm']['name'] do |vb|
  end

  cache_apt = vcache(config.vm.box)
  config.vm.synced_folder cache_apt, "/var/cache/apt/archives/", type: "nfs", nfs_udp: false
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.synced_folder ".", "/srv/shared", type: "nfs", nfs_udp: false

  config.vm.provision "shell", run: "always", inline: "cat /etc/network/interfaces | grep -v 'post-up' | tee /etc/network/interfaces 1>/dev/null 2>&1 ; sed -i.bak 's/timeout=-1/timeout=1/' /etc/grub.d/00_header ; rm /etc/grub.d/00_header.bak"
  config.vm.provision "shell", path: "./provision/provisioner.sh"
end

def vcache(box_name)
  cache_dir = File.join(File.expand_path("~"), '.vagrant.d', 'cache', 'apt', box_name)
  partial_dir = File.join(cache_dir, 'partial')
  FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir
  cache_dir
end

VagrantFile (Windows + Hyper-V)
require "yaml"
require "fileutils"

CONF = YAML.load(File.open(File.join(File.dirname(__FILE__), "provision/config.yml"), File::RDONLY).read)

Vagrant.configure("2") do |config|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

config.vm.box = "hashicorp/precise64"

config.vm.hostname = CONF['vm']['name']
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
#config.vm.network "public_network"

config.vm.provider "hyperv" do |h|
h.vmname = CONF['vm']['name']
h.memory = CONF['vm']['memory']
h.enable_virtualization_extensions = true

h.vm_integration_services = {
guest_service_interface: true,
heartbeat: true,
key_value_pair_exchange: true,
shutdown: true,
time_synchronization: true,
vss: true
}
end

config.vm.define CONF['vm']['name'] do |h|
end

config.vm.synced_folder ".", "/srv/shared", type: "rsync", rsync__exclude: ".git/", rsync__args: ["--verbose", "--rsync-path='rsync'", "--archive", "--delete", "-z"]
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provision "shell", run: "always", inline: "cat /etc/network/interfaces | grep -v 'post-up' | tee /etc/network/interfaces 1>/dev/null 2>&1 ; sed -i.bak 's/timeout=-1/timeout=1/' /etc/grub.d/00_header ; rm /etc/grub.d/00_header.bak"
config.vm.provision "shell", path: "./provision/provisioner.sh"
end

I get no errors from provision.sh on both cases. But just in case, here it is (attached). 

Config.yaml only contains the machine name and the DB name (both the same and irrelevant here). 

Thank you in advance. 

Evandro


provisioner.sh

Alvaro Miranda Aguilera

unread,
Aug 26, 2017, 7:49:20 PM8/26/17
to vagra...@googlegroups.com
what happpens if your php page is simple and only displays php_info() ?

Networking in may be different, so you could login to the guest and try to curl the page and see if its working

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/82a373ce-5a36-4b6a-9bd6-0d45687f2cbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

evand...@outlook.com

unread,
Aug 26, 2017, 11:38:14 PM8/26/17
to Vagrant
It does display PHP's configuration as usual. 
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Aug 27, 2017, 5:03:04 PM8/27/17
to vagra...@googlegroups.com
so, php+webserver+provision is working

i think is something related to networking, virtualbox and hyper-v i think use different networks, so not sure the same script will work on both 

check around virtual host and the names configured in the webserver

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/105baa7e-62cf-495e-a23a-fa9f41983a67%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages