Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
| 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! |
| 5 | VAGRANTFILE_API_VERSION = "2" |
| 6 | |
| 7 | $setup = <<SCRIPT |
| 8 | sudo apt-get update -qq |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 9 | SCRIPT |
| 10 | |
| 11 | $setup_integ = <<SCRIPT |
| 12 | cp -R /vagrant integration-tests |
| 13 | cd integration-tests && ./install_apps.py install_all 2>&1 | tee install.log |
| 14 | SCRIPT |
| 15 | |
| 16 | $setup_ssh = <<SCRIPT |
| 17 | mkdir -p ~/.ssh |
| 18 | cp /vagrant/temp/sshkey ~/.ssh/id_rsa |
| 19 | cp /vagrant/temp/sshkey.pub ~/.ssh/id_rsa.pub |
| 20 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
| 21 | chown -R vagrant:vagrant ~/.ssh |
| 22 | chmod -R 700 ~/.ssh |
| 23 | SCRIPT |
| 24 | |
| 25 | $setup_a = <<SCRIPT |
| 26 | cat > ~/.ssh/config <<EOF |
| 27 | Host 192.168.*.* |
| 28 | StrictHostKeyChecking no |
| 29 | EOF |
| 30 | |
| 31 | sudo ip route add 192.168.3.0/24 via 192.168.2.3 |
| 32 | sudo ip -6 addr add fd01::3/64 dev eth1 |
| 33 | sudo ip -6 addr add fd02::2/64 dev eth2 |
| 34 | sudo ip -6 route add fd03::/64 via fd02::3 |
| 35 | SCRIPT |
| 36 | |
| 37 | $setup_d = <<SCRIPT |
| 38 | ip route add 192.168.2.0/24 via 192.168.3.2 |
| 39 | ip -6 addr add fd03::3/64 dev eth1 |
| 40 | ip -6 route add fd02::/64 via fd03::2 |
| 41 | SCRIPT |
| 42 | |
| 43 | $setup_router = <<SCRIPT |
| 44 | echo 1 > /proc/sys/net/ipv4/ip_forward |
| 45 | echo 1 > /proc/sys/net/ipv6/conf/all/forwarding |
| 46 | ip -6 addr add fd02::3/64 dev eth1 |
| 47 | ip -6 addr add fd03::2/64 dev eth2 |
| 48 | SCRIPT |
| 49 | |
| 50 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
Eric Newberry | 7a77f33 | 2015-07-23 20:29:31 -0700 | [diff] [blame] | 51 | config.vm.box = "ubuntu/trusty64" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 52 | |
| 53 | config.vm.provider "virtualbox" do |vb| |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 54 | vb.memory = "2048" |
| 55 | vb.cpus = "1" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 56 | vb.customize ["storagectl", :id, "--name", "SATAController", "--hostiocache", "off"] |
| 57 | end |
| 58 | |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 59 | config.vm.define "template" do |t| |
| 60 | t.vm.provision "shell", inline: $setup, privileged: false |
| 61 | t.vm.provision "shell", inline: $setup_ssh, privileged: false |
| 62 | t.vm.provision "shell", inline: $setup_integ, privileged: false |
| 63 | end |
| 64 | |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 65 | config.vm.define "A" do |a| |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 66 | a.vm.box = "nfd-integ" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 67 | a.vm.network "private_network", ip: "192.168.1.3", virtualbox__intnet: "ABC-switch" |
| 68 | a.vm.network "private_network", ip: "192.168.2.2", virtualbox__intnet: "AtoRouter" |
| 69 | a.vm.provision "shell", inline: $setup, privileged: false |
| 70 | a.vm.provision "shell", inline: $setup_a, privileged: false |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 71 | end |
| 72 | |
| 73 | config.vm.define "B" do |b| |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 74 | b.vm.box = "nfd-integ" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 75 | b.vm.network "private_network", ip: "192.168.1.2", virtualbox__intnet: "ABC-switch" |
| 76 | b.vm.provision "shell", inline: $setup, privileged: false |
| 77 | b.vm.provision "shell", inline: "ip -6 addr add fd01::2/64 dev eth1" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 78 | end |
| 79 | |
| 80 | config.vm.define "C" do |c| |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 81 | c.vm.box = "nfd-integ" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 82 | c.vm.network "private_network", ip: "192.168.1.4", virtualbox__intnet: "ABC-switch" |
| 83 | c.vm.provision "shell", inline: $setup, privileged: false |
| 84 | c.vm.provision "shell", inline: "ip -6 addr add fd01::4/64 dev eth1" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 85 | end |
| 86 | |
| 87 | config.vm.define "D" do |d| |
Eric Newberry | 8ab30bb | 2015-09-26 11:56:40 -0700 | [diff] [blame] | 88 | d.vm.box = "nfd-integ" |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 89 | d.vm.network "private_network", ip: "192.168.3.3", virtualbox__intnet: "DtoRouter" |
| 90 | d.vm.provision "shell", inline: $setup, privileged: false |
| 91 | d.vm.provision "shell", inline: $setup_d |
Eric Newberry | e69cb69 | 2015-07-08 22:46:01 -0700 | [diff] [blame] | 92 | end |
| 93 | |
| 94 | config.vm.define "router" do |router| |
| 95 | router.vm.network "private_network", ip: "192.168.2.3", virtualbox__intnet: "AtoRouter" |
| 96 | router.vm.network "private_network", ip: "192.168.3.2", virtualbox__intnet: "DtoRouter" |
| 97 | router.vm.provision "shell", inline: $setup_router |
| 98 | router.vm.provider "virtualbox" do |vb| |
| 99 | vb.memory = "128" |
| 100 | vb.cpus = "1" |
| 101 | end |
| 102 | end |
| 103 | end |