diff --git a/labs/Vagrantfile b/labs/Vagrantfile index dc00deea..a03fe278 100644 --- a/labs/Vagrantfile +++ b/labs/Vagrantfile @@ -80,8 +80,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if prefix == "controller" or prefix == "allinone" box.vm.network "forwarded_port", guest: 80, host: 8080 end - # Run the shell provisioning script file - box.vm.provision :shell, :path => "#{prefix}.sh" + # Run the shell provisioning script file (as root) + box.vm.provision :shell, :path => "scripts/vagrant/#{prefix}.sh" # Advanced VirtualBox settings box.vm.provider :virtualbox do |vbox| # Single node resource allocations; will be more selective for diff --git a/labs/scripts/vagrant/allinone.sh b/labs/scripts/vagrant/allinone.sh new file mode 120000 index 00000000..f531795a --- /dev/null +++ b/labs/scripts/vagrant/allinone.sh @@ -0,0 +1 @@ +run_scripts.sh \ No newline at end of file diff --git a/labs/scripts/vagrant/compute.sh b/labs/scripts/vagrant/compute.sh new file mode 120000 index 00000000..f531795a --- /dev/null +++ b/labs/scripts/vagrant/compute.sh @@ -0,0 +1 @@ +run_scripts.sh \ No newline at end of file diff --git a/labs/scripts/vagrant/controller.sh b/labs/scripts/vagrant/controller.sh new file mode 120000 index 00000000..f531795a --- /dev/null +++ b/labs/scripts/vagrant/controller.sh @@ -0,0 +1 @@ +run_scripts.sh \ No newline at end of file diff --git a/labs/scripts/vagrant/network.sh b/labs/scripts/vagrant/network.sh new file mode 120000 index 00000000..f531795a --- /dev/null +++ b/labs/scripts/vagrant/network.sh @@ -0,0 +1 @@ +run_scripts.sh \ No newline at end of file diff --git a/labs/scripts/vagrant/run_scripts.sh b/labs/scripts/vagrant/run_scripts.sh new file mode 100644 index 00000000..20f67a0f --- /dev/null +++ b/labs/scripts/vagrant/run_scripts.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -o errexit + +# Shell provisioning script is renamed and copied to /tmp before being run as +# root +TOP_DIR=/vagrant +source "$TOP_DIR/config/paths" +source "$LIB_DIR/functions.guest" + +clean_dir "$LOG_DIR" + +exec_logpath "$LOG_DIR/$HOSTNAME.log" + +# The Vagrantfile uses precise, so we know it's Ubuntu +for CONFIG_FILE in "scripts.nodeinit_vagrant" "scripts.ubuntu" "scripts.$HOSTNAME"; do + echo "Config file $CONFIG_FILE" + get_script_paths_from_config "$CONFIG_FILE" | while read SCR_PATH; do + echo "$SCR_PATH" + as_root_exec_script "$SCR_PATH" + done +done