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.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