2015-09-11 21:58:16 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
2017-09-07 18:49:22 +00:00
|
|
|
#
|
|
|
|
|
2020-07-15 15:10:57 +00:00
|
|
|
LINUX_BASE_BOX = "bento/ubuntu-18.04"
|
2019-11-06 13:58:34 +00:00
|
|
|
FREEBSD_BASE_BOX = "freebsd/FreeBSD-11.3-STABLE"
|
2017-09-07 18:49:22 +00:00
|
|
|
|
2021-11-24 15:45:58 +00:00
|
|
|
LINUX_IP_ADDRESS = "192.168.56.200"
|
2019-09-06 18:27:26 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
Vagrant.configure(2) do |config|
|
|
|
|
# Compilation and development boxes
|
|
|
|
config.vm.define "linux", autostart: true, primary: true do |vmCfg|
|
|
|
|
vmCfg.vm.box = LINUX_BASE_BOX
|
|
|
|
vmCfg.vm.hostname = "linux"
|
|
|
|
vmCfg = configureProviders vmCfg,
|
|
|
|
cpus: suggestedCPUCores()
|
|
|
|
|
|
|
|
vmCfg = configureLinuxProvisioners(vmCfg)
|
|
|
|
|
2021-10-27 10:15:37 +00:00
|
|
|
# Expose Nomad and Consul ports for ease.
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 4646, host: 4646, auto_correct: true, host_ip: "127.0.0.1"
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 8500, host: 8500, auto_correct: true, host_ip: "127.0.0.1"
|
|
|
|
|
2018-06-11 23:07:06 +00:00
|
|
|
vmCfg.vm.synced_folder '.',
|
|
|
|
'/opt/gopath/src/github.com/hashicorp/nomad'
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: false,
|
|
|
|
path: './scripts/vagrant-linux-unpriv-bootstrap.sh'
|
2019-09-06 18:27:26 +00:00
|
|
|
|
|
|
|
vmCfg.vm.provider "virtualbox" do |_|
|
|
|
|
vmCfg.vm.network :private_network, ip: LINUX_IP_ADDRESS
|
|
|
|
end
|
2018-06-11 23:07:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.define "linux-ui", autostart: false, primary: false do |vmCfg|
|
|
|
|
vmCfg.vm.box = LINUX_BASE_BOX
|
|
|
|
vmCfg.vm.hostname = "linux"
|
|
|
|
vmCfg = configureProviders vmCfg,
|
|
|
|
cpus: suggestedCPUCores()
|
|
|
|
|
|
|
|
vmCfg = configureLinuxProvisioners(vmCfg)
|
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.synced_folder '.',
|
|
|
|
'/opt/gopath/src/github.com/hashicorp/nomad'
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
2017-09-12 05:38:10 +00:00
|
|
|
privileged: false,
|
2017-09-07 18:49:22 +00:00
|
|
|
path: './scripts/vagrant-linux-unpriv-bootstrap.sh'
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-09-11 18:53:30 +00:00
|
|
|
# Expose the nomad api and ui to the host
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 4646, host: 4646, auto_correct: true
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 8500, host: 8500, auto_correct: true
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-09-11 18:53:30 +00:00
|
|
|
# Expose Ember ports to the host (one for the site, one for livereload)
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 4201, host: 4201, auto_correct: true
|
|
|
|
vmCfg.vm.network :forwarded_port, guest: 49153, host: 49153, auto_correct: true
|
2017-09-07 18:49:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.define "freebsd", autostart: false, primary: false do |vmCfg|
|
|
|
|
vmCfg.vm.box = FREEBSD_BASE_BOX
|
|
|
|
vmCfg.vm.hostname = "freebsd"
|
2019-03-14 03:58:25 +00:00
|
|
|
vmCfg.ssh.shell = "sh"
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg = configureProviders vmCfg,
|
|
|
|
cpus: suggestedCPUCores()
|
2019-03-14 03:58:25 +00:00
|
|
|
vmCfg.vm.network "private_network", type: "dhcp"
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.synced_folder '.',
|
|
|
|
'/opt/gopath/src/github.com/hashicorp/nomad',
|
|
|
|
type: "nfs",
|
|
|
|
bsd__nfs_options: ['noatime']
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
|
|
|
path: './scripts/vagrant-freebsd-priv-config.sh'
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: false,
|
|
|
|
path: './scripts/vagrant-freebsd-unpriv-bootstrap.sh'
|
2017-09-19 14:47:10 +00:00
|
|
|
end
|
2017-09-07 18:49:22 +00:00
|
|
|
|
|
|
|
# Test Cluster (Linux)
|
|
|
|
1.upto(3) do |n|
|
|
|
|
serverName = "nomad-server%02d" % [n]
|
|
|
|
clientName = "nomad-client%02d" % [n]
|
2021-11-24 15:45:58 +00:00
|
|
|
serverIP = "192.168.56.%d" % [10 + n]
|
|
|
|
clientIP = "192.168.56.%d" % [20 + n]
|
2017-09-07 18:49:22 +00:00
|
|
|
|
|
|
|
config.vm.define serverName, autostart: false, primary: false do |vmCfg|
|
|
|
|
vmCfg.vm.box = LINUX_BASE_BOX
|
|
|
|
vmCfg.vm.hostname = serverName
|
|
|
|
vmCfg = configureProviders(vmCfg)
|
|
|
|
vmCfg = configureLinuxProvisioners(vmCfg)
|
|
|
|
|
|
|
|
vmCfg.vm.provider "virtualbox" do |_|
|
|
|
|
vmCfg.vm.network :private_network, ip: serverIP
|
|
|
|
end
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.synced_folder '.',
|
|
|
|
'/opt/gopath/src/github.com/hashicorp/nomad'
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
|
|
|
path: './scripts/vagrant-linux-priv-zeroconf.sh'
|
|
|
|
end
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
config.vm.define clientName, autostart: false, primary: false do |vmCfg|
|
|
|
|
vmCfg.vm.box = LINUX_BASE_BOX
|
|
|
|
vmCfg.vm.hostname = clientName
|
|
|
|
vmCfg = configureProviders(vmCfg)
|
|
|
|
vmCfg = configureLinuxProvisioners(vmCfg)
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.provider "virtualbox" do |_|
|
|
|
|
vmCfg.vm.network :private_network, ip: clientIP
|
|
|
|
end
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.synced_folder '.',
|
|
|
|
'/opt/gopath/src/github.com/hashicorp/nomad'
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
|
|
|
path: './scripts/vagrant-linux-priv-zeroconf.sh'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def configureLinuxProvisioners(vmCfg)
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
|
|
|
inline: 'rm -f /home/vagrant/linux.iso'
|
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
2017-09-08 23:59:03 +00:00
|
|
|
privileged: true,
|
2023-03-28 13:18:48 +00:00
|
|
|
path: './scripts/linux-priv-go.sh'
|
2017-09-08 23:59:03 +00:00
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
2017-09-07 18:49:22 +00:00
|
|
|
privileged: true,
|
2023-03-27 16:13:18 +00:00
|
|
|
path: './scripts/linux-priv-config.sh'
|
2017-09-07 18:49:22 +00:00
|
|
|
|
2019-03-14 11:45:49 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
2023-03-28 15:21:14 +00:00
|
|
|
path: './scripts/linux-priv-dev.sh'
|
2019-03-14 11:45:49 +00:00
|
|
|
|
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
2023-03-28 15:21:14 +00:00
|
|
|
path: './scripts/linux-priv-docker.sh'
|
2019-03-14 11:45:49 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
2023-03-28 15:21:14 +00:00
|
|
|
path: './scripts/linux-priv-consul.sh'
|
2017-09-07 18:49:22 +00:00
|
|
|
|
2019-09-05 18:12:39 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
2023-03-28 15:21:14 +00:00
|
|
|
path: './scripts/linux-priv-cni.sh'
|
2019-09-05 18:12:39 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
|
|
|
privileged: true,
|
2023-03-28 15:21:14 +00:00
|
|
|
path: './scripts/linux-priv-vault.sh'
|
2017-09-07 18:49:22 +00:00
|
|
|
|
2018-07-31 19:25:48 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
2018-10-04 19:05:23 +00:00
|
|
|
privileged: false,
|
2018-10-05 14:07:05 +00:00
|
|
|
path: './scripts/vagrant-linux-unpriv-ui.sh'
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2018-08-01 20:27:06 +00:00
|
|
|
vmCfg.vm.provision "shell",
|
2018-08-01 20:50:40 +00:00
|
|
|
privileged: true,
|
2020-11-17 15:01:48 +00:00
|
|
|
path: './scripts/vagrant-linux-priv-buf.sh'
|
2018-08-01 20:27:06 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
return vmCfg
|
|
|
|
end
|
2015-09-11 21:58:16 +00:00
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
def configureProviders(vmCfg, cpus: "2", memory: "2048")
|
|
|
|
vmCfg.vm.provider "virtualbox" do |v|
|
2018-02-15 05:30:11 +00:00
|
|
|
v.customize ["modifyvm", :id, "--cableconnected1", "on"]
|
2017-09-07 18:49:22 +00:00
|
|
|
v.memory = memory
|
|
|
|
v.cpus = cpus
|
|
|
|
end
|
|
|
|
|
|
|
|
["vmware_fusion", "vmware_workstation"].each do |p|
|
|
|
|
vmCfg.vm.provider p do |v|
|
|
|
|
v.enable_vmrun_ip_lookup = false
|
|
|
|
v.vmx["memsize"] = memory
|
|
|
|
v.vmx["numvcpus"] = cpus
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
vmCfg.vm.provider "virtualbox" do |v|
|
2020-02-03 16:26:41 +00:00
|
|
|
v.customize ["modifyvm", :id, "--cableconnected1", "on", "--audio", "none"]
|
2017-09-07 18:49:22 +00:00
|
|
|
v.memory = memory
|
|
|
|
v.cpus = cpus
|
|
|
|
end
|
|
|
|
|
|
|
|
return vmCfg
|
2016-05-05 18:07:02 +00:00
|
|
|
end
|
|
|
|
|
2017-09-07 18:49:22 +00:00
|
|
|
def suggestedCPUCores()
|
|
|
|
case RbConfig::CONFIG['host_os']
|
|
|
|
when /darwin/
|
|
|
|
Integer(`sysctl -n hw.ncpu`) / 2
|
|
|
|
when /linux/
|
2018-04-16 07:11:20 +00:00
|
|
|
Integer(`grep -c ^processor /proc/cpuinfo`) / 2
|
2017-09-07 18:49:22 +00:00
|
|
|
else
|
|
|
|
2
|
|
|
|
end
|
2015-09-11 21:58:16 +00:00
|
|
|
end
|