From f8ff0463b06159292201aa8e7da63f73db3978da Mon Sep 17 00:00:00 2001 From: James Nugent Date: Thu, 7 Sep 2017 13:49:22 -0500 Subject: [PATCH] build: Rework Vagrant to support multiple OS boxes This commit reworks the Vagrantfile for Nomad in order to support straightforward testing on more than one operating system, whilst retaining the ability to stand up a test cluster running Ubuntu. The following changes are made: - Scripts have been extracted from the Vagrantfile into their own shell script files, in order that editors lint them. - All scripts have been edited to lint with no warnings or errors for their respective shells. - Scripts are named according to the operating system and privilege level which they run. We prefer to run a whole shell script as root versus prefixing (essentially) every command with `sudo` or an equivalent. - The Linux development box has been separated from the test cluster, removing some of the more gnarly (and less portable) logic. The Linux development box is still primary and autostarts. - A FreeBSD target has been added. The base box works for both Virtualbox and VMWare Fusion. - A target is added to the GNUmakefile to stand up a test cluster, using the default provider, or overriding the provider by setting the PROVIDER variable in make: - `make testcluster` - `make testcluster PROVIDER=vmware_fusion` - Machines in the test cluster have Avahi configured for zeroconf discovery. Each machine can ping each other machine at `hostname.local` - for example `nomad-server02.local`, `nomad-client03.local`. --- GNUmakefile | 10 + Vagrantfile | 259 ++++++++++---------- scripts/install_consul.sh | 20 -- scripts/install_rkt.sh | 25 -- scripts/install_rkt_vagrant.sh | 11 - scripts/install_vault.sh | 20 -- scripts/vagrant-freebsd-priv-config.sh | 35 +++ scripts/vagrant-freebsd-unpriv-bootstrap.sh | 8 + scripts/vagrant-linux-priv-config.sh | 107 ++++++++ scripts/vagrant-linux-priv-consul.sh | 22 ++ scripts/vagrant-linux-priv-rkt.sh | 47 ++++ scripts/vagrant-linux-priv-vault.sh | 22 ++ scripts/vagrant-linux-priv-zeroconf.sh | 10 + scripts/vagrant-linux-unpriv-bootstrap.sh | 3 + 14 files changed, 389 insertions(+), 210 deletions(-) delete mode 100755 scripts/install_consul.sh delete mode 100755 scripts/install_rkt.sh delete mode 100755 scripts/install_rkt_vagrant.sh delete mode 100755 scripts/install_vault.sh create mode 100755 scripts/vagrant-freebsd-priv-config.sh create mode 100755 scripts/vagrant-freebsd-unpriv-bootstrap.sh create mode 100755 scripts/vagrant-linux-priv-config.sh create mode 100755 scripts/vagrant-linux-priv-consul.sh create mode 100755 scripts/vagrant-linux-priv-rkt.sh create mode 100755 scripts/vagrant-linux-priv-vault.sh create mode 100644 scripts/vagrant-linux-priv-zeroconf.sh create mode 100755 scripts/vagrant-linux-unpriv-bootstrap.sh diff --git a/GNUmakefile b/GNUmakefile index 11468d2b5..c309d651b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -214,6 +214,16 @@ clean: ## Remove build artifacts travis: ## Run Nomad test suites with output to prevent timeouts under Travis CI @sh -C "$(PROJECT_ROOT)/scripts/travis.sh" +.PHONY: testcluster +testcluster: ## Bring up a Linux test cluster using Vagrant. Set PROVIDER if necessary. + vagrant up nomad-server01 \ + nomad-server02 \ + nomad-server03 \ + nomad-client01 \ + nomad-client02 \ + nomad-client03 \ + $(if $(PROVIDER),--provider $(PROVIDER)) + HELP_FORMAT=" \033[36m%-25s\033[0m %s\n" .PHONY: help help: ## Display this usage information diff --git a/Vagrantfile b/Vagrantfile index 72164be68..5429b5e98 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,155 +1,146 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" +LINUX_BASE_BOX = "bento/ubuntu-16.04" +FREEBSD_BASE_BOX = "jen20/FreeBSD-11.1-RELEASE" -DEFAULT_CPU_COUNT = 2 -$script = <