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.box_url = "http://files.vagrantup.com/precise64.box";

  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.box_url = "http://files.vagrantup.com/precise64.box";;

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


-- 
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+unsubscr...@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.
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
rm -rf /vagrant
mkdir -p /srv/shared/.tmp

echo "+ configure profile"
echo "CURRENT_IP=\$(ifconfig eth1 | grep 'inet addr' | awk '{print \$2}')" > /home/vagrant/.bash_profile
echo 'echo -e "\nCurrent IP ${CURRENT_IP}\n"' >> /home/vagrant/.bash_profile
echo "cd /srv/shared" >> /home/vagrant/.bash_profile

echo "+ update apt repository"
apt-get -q -y update 1>/dev/null 2>&1

echo "+ install htop"
apt-get -q -y install htop 1>/dev/null 2>&1

echo "+ install postfix"
debconf-set-selections <<< "postfix postfix/mailname string localhost"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
apt-get install -q -y postfix 1>/dev/null 2>&1
sed -i.bkp -e 's/inet_interfaces.*/inet_interfaces = localhost/' /etc/postfix/main.cf
sed -i.bkp -e 's/mydestination.*/mydestination = /' /etc/postfix/main.cf
rm -f /etc/postfix/*.bkp
service postfix restart 1>/dev/null 2>&1

echo "+ install unzip"
apt-get -q -y install unzip -qq 1>/dev/null 2>&1

echo "+ install apache2"
apt-get -q -y install apache2 1>/dev/null 2>&1
apt-get -q -y install libapache2-mod-php5 1>/dev/null 2>&1

echo "+ enable apache modules"
/usr/sbin/a2enmod rewrite 1>/dev/null 2>&1

echo "+ configure vhost"
rm -f /etc/apache2/sites-enabled/*
ln -sf /srv/shared/provision/httpd/default /etc/apache2/sites-enabled/default
service apache2 restart 1>/dev/null 2>&1

echo "+ install mysql server and client"
apt-get -q -y install mysql-server mysql-client 1>/dev/null 2>&1
service mysql restart 1>/dev/null 2>&1

echo "+ provisioning database"
bash /srv/shared/provision/database.sh
if [ $? -ne 0 ]; then
  echo "ERROR: failed on database provisioning"
fi

echo "+ install php5"
apt-get -q -y install php5 php5-mysql php5-json php5-mcrypt 1>/dev/null 2>&1
service apache2 restart 1>/dev/null 2>&1

echo "+ install git, make, imagemagick, curl"
apt-get -q -y install git make imagemagick curl 1>/dev/null 2>&1

echo "+ install node.js and npm"
git clone https://github.com/visionmedia/n.git /opt/n  1>/dev/null 2>&1
cd /opt/n
make install  1>/dev/null 2>&1
n stable  1>/dev/null 2>&1

echo "+ install required global NPM packages"
npm install -g grunt-cli 1>/dev/null 2>&1

echo "+ install composer"
cd /usr/bin/ ; curl -Ss https://getcomposer.org/installer | php 1>/dev/null 2>&1

echo "+ project setup"
cd /srv/shared/src/ ; grunt build 1>/dev/null 2>&1
VM_NAME=$(cat /srv/shared/provision/config.yml | grep name: | head -n 1 | sed -e 's/.*name: \(.*\)/\1/')
sed -i.bak -e "s/your-machine-name/${VM_NAME}/" /srv/shared/server/app/config/app.php
rm -f /srv/shared/server/app/config/app.php.bak

exit 0

Reply via email to