From a5482a0208cf269e49ff53e7e33cffe3b0cd7551 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Sun, 20 Jan 2019 00:27:49 +0100 Subject: [PATCH] create .online file to do an online deployment. --- .gitignore | 2 +- Vagrantfile | 18 +++++++++++------- provision.sh | 11 +++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index ef54c64..2a62bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ ##### .gitignore default file. ##### .vagrant - +.online ### ignore temp/backup stuff ### *~ diff --git a/Vagrantfile b/Vagrantfile index 9cc6e53..04392c2 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,6 +4,11 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |v| v.name = "aic18g6t4" v.memory = 2048 + + # online deployment: needed to assign a fixed ip. + if File.exist?(".online") + config.vm.network "public_network", adapter: 2, type: "dhcp", mac: "080808080808" + end end config.vm.provider "libvirt" do |v| @@ -15,13 +20,12 @@ Vagrant.configure("2") do |config| # design-choice: run file in vm. config.vm.provision "shell", inline: "/vagrant/provision.sh" - config.vm.network "forwarded_port", guest: 8080, host: 8080 + config.vm.network "forwarded_port", adapter: 1, guest: 8080, host: 8080 # only for debugging reasons? - config.vm.network "forwarded_port", guest: 8081, host: 8081 - config.vm.network "forwarded_port", guest: 8082, host: 8082 - config.vm.network "forwarded_port", guest: 8083, host: 8083 - config.vm.network "forwarded_port", guest: 8084, host: 8084 - config.vm.network "forwarded_port", guest: 8085, host: 8085 - + config.vm.network "forwarded_port", adapter: 1, guest: 8081, host: 8081 + config.vm.network "forwarded_port", adapter: 1, guest: 8082, host: 8082 + config.vm.network "forwarded_port", adapter: 1, guest: 8083, host: 8083 + config.vm.network "forwarded_port", adapter: 1, guest: 8084, host: 8084 + config.vm.network "forwarded_port", adapter: 1, guest: 8085, host: 8085 end diff --git a/provision.sh b/provision.sh index d351082..3fbfaa7 100755 --- a/provision.sh +++ b/provision.sh @@ -2,6 +2,17 @@ cd /vagrant + +################################################## +# Fix default gateway on publically reachable VM # +################################################## +if [ -f /vagrant/.online ]; then + echo "ONLINE-provisioning detected. Fixing network." + ip route del default + ip route add default via 10.11.0.254 dev eth1 +fi + + ############################### # Get Docker + Docker-Compose # ############################### -- 2.43.0