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