Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
| 4 | Vagrant.configure(2) do |config| |
| 5 | |
| 6 | if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 7 | config.vm.synced_folder "..", "/cord", mount_options: ["dmode=700,fmode=600"] |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 8 | else |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 9 | config.vm.synced_folder "..", "/cord" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 10 | end |
| 11 | |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 12 | #By default, this variable is set to 2, such that Vagrantfile allows creation |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 13 | #of compute nodes up to 2. If the number of compute nodes to be supported more |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 14 | #than 2, set the environment variable NUM_COMPUTE_NODES to the desired value |
| 15 | #before executing this Vagrantfile. |
| 16 | num_compute_nodes = (ENV['NUM_COMPUTE_NODES'] || 2).to_i |
| 17 | compute_ip_base = "10.6.1." |
| 18 | compute_ips = num_compute_nodes.times.collect { |n| compute_ip_base + "#{n+2}" } |
| 19 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 20 | config.vm.define "corddev" do |d| |
Zsolt Haraszti | 5b5a42a | 2016-05-12 22:19:57 -0700 | [diff] [blame] | 21 | d.ssh.forward_agent = true |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 22 | d.vm.box = "ubuntu/trusty64" |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 23 | d.vm.synced_folder '.', '/vagrant', disabled: true |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 24 | d.vm.hostname = "corddev" |
| 25 | d.vm.network "private_network", ip: "10.100.198.200" |
David K. Bainbridge | 0bdec19 | 2016-10-13 18:10:10 -0700 | [diff] [blame] | 26 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
| 27 | d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/corddev.yml -c local" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 28 | d.vm.provider "virtualbox" do |v| |
| 29 | v.memory = 2048 |
| 30 | end |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 31 | d.vm.provider :libvirt do |v, override| |
Andy Bavier | 8ce395f | 2016-10-14 12:51:30 -0400 | [diff] [blame] | 32 | v.memory = 2048 |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 33 | override.vm.synced_folder "..", "/cord", type: "nfs" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 34 | end |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 35 | end |
| 36 | |
| 37 | config.vm.define "prod" do |d| |
| 38 | d.vm.box = "ubuntu/trusty64" |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 39 | d.vm.synced_folder '.', '/vagrant', disabled: true |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 40 | d.vm.hostname = "prod" |
Andy Bavier | 51584d4 | 2016-12-02 08:39:13 -0500 | [diff] [blame] | 41 | d.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: '*' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 42 | d.vm.network "private_network", ip: "10.100.198.201" |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 43 | d.vm.network "private_network", |
| 44 | ip: "0.0.0.0", |
| 45 | auto_config: false, |
| 46 | virtualbox__intnet: "cord-mgmt-network", |
| 47 | libvirt__network_name: "cord-mgmt-network", |
| 48 | libvirt__forward_mode: "none", |
| 49 | libvirt__dhcp_enabled: false |
| 50 | d.vm.network "private_network", |
| 51 | ip: "10.6.1.201", # To set up the 10.6.1.1 IP address on bridge |
| 52 | virtualbox__intnet: "cord-fabric-network", |
| 53 | libvirt__network_name: "cord-fabric-network", |
| 54 | libvirt__forward_mode: "nat", |
| 55 | libvirt__dhcp_enabled: false |
David K. Bainbridge | 6f2cbe7 | 2016-08-19 15:48:07 -0700 | [diff] [blame] | 56 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 57 | d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/prod.yml -c local" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 58 | d.vm.provider "virtualbox" do |v| |
David K. Bainbridge | 97b3f2f | 2016-06-16 18:08:49 -0700 | [diff] [blame] | 59 | v.memory = 2048 |
| 60 | end |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 61 | d.vm.provider :libvirt do |v, override| |
| 62 | v.memory = 16384 |
| 63 | v.cpus = 8 |
| 64 | v.storage :file, :size => '100G', :type => 'qcow2' |
Andy Bavier | 750bc6b | 2016-12-01 06:53:57 -0500 | [diff] [blame] | 65 | override.vm.synced_folder "..", "/cord", type: "nfs" |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 66 | override.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/add-extra-drive.yml -c local" |
| 67 | end |
David K. Bainbridge | 97b3f2f | 2016-06-16 18:08:49 -0700 | [diff] [blame] | 68 | end |
| 69 | |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 70 | config.vm.define "switch" do |s| |
| 71 | s.vm.box = "ubuntu/trusty64" |
| 72 | s.vm.hostname = "fakeswitch" |
| 73 | s.vm.network "private_network", ip: "10.100.198.253" |
| 74 | s.vm.network "private_network", |
| 75 | type: "dhcp", |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 76 | virtualbox__intnet: "cord-fabric-network", |
| 77 | libvirt__network_name: "cord-fabric-network", |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 78 | mac: "cc37ab000001" |
| 79 | s.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 80 | s.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/fakeswitch.yml -c local" |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 81 | s.vm.provider "virtualbox" do |v| |
David K. Bainbridge | 97b3f2f | 2016-06-16 18:08:49 -0700 | [diff] [blame] | 82 | v.memory = 1048 |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 83 | v.name = "fakeswitch" |
| 84 | end |
| 85 | end |
| 86 | |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 87 | config.vm.define "testbox" do |d| |
| 88 | d.vm.box = "fgrehm/trusty64-lxc" |
| 89 | d.ssh.forward_agent = true |
| 90 | d.vm.hostname = "testbox" |
| 91 | d.vm.network "private_network", ip: "10.0.3.100", lxc__bridge_name: 'lxcbr0' |
| 92 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
| 93 | d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/corddev.yml -c local" |
| 94 | config.vm.provider :lxc do |lxc| |
| 95 | # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox |
| 96 | lxc.customize 'cgroup.memory.limit_in_bytes', '2048M' |
alshabib | 270d766 | 2016-09-06 14:09:18 -0700 | [diff] [blame] | 97 | lxc.customize 'aa_profile', 'unconfined' |
| 98 | lxc.customize 'cgroup.devices.allow', 'b 7:* rwm' |
| 99 | lxc.customize 'cgroup.devices.allow', 'c 10:237 rwm' |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 100 | end |
David K. Bainbridge | a0a36e9 | 2016-10-13 18:05:33 -0700 | [diff] [blame] | 101 | end |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 102 | |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 103 | num_compute_nodes.times do |n| |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 104 | config.vm.define "compute_node-#{n+1}" do |c| |
| 105 | compute_ip = compute_ips[n] |
| 106 | compute_index = n+1 |
| 107 | c.vm.synced_folder '.', '/vagrant', disabled: true |
| 108 | c.vm.communicator = "none" |
| 109 | c.vm.hostname = "computenode-#{compute_index}" |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 110 | c.vm.network "private_network", |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 111 | adapter: 1, |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 112 | ip: "0.0.0.0", |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 113 | auto_config: false, |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 114 | virtualbox__intnet: "cord-mgmt-network", |
| 115 | libvirt__network_name: "cord-mgmt-network" |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 116 | c.vm.network "private_network", |
| 117 | adapter: 2, |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 118 | ip: "#{compute_ip}", |
| 119 | auto_config: false, |
| 120 | virtualbox__intnet: "cord-fabric-network", |
| 121 | libvirt__network_name: "cord-fabric-network", |
| 122 | libvirt__forward_mode: "nat", |
| 123 | libvirt__dhcp_enabled: false |
| 124 | c.vm.provider :libvirt do |v| |
| 125 | v.memory = 8192 |
| 126 | v.cpus = 4 |
| 127 | v.machine_virtual_size = 100 |
| 128 | v.storage :file, :size => '100G', :type => 'qcow2' |
| 129 | v.boot 'network' |
| 130 | v.boot 'hd' |
| 131 | v.nested = true |
| 132 | end |
| 133 | c.vm.provider "virtualbox" do |v, override| |
| 134 | override.vm.box = "clink15/pxe" |
| 135 | v.memory = 1048 |
| 136 | v.gui = "true" |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 137 | end |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 138 | end |
| 139 | end |
| 140 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 141 | if Vagrant.has_plugin?("vagrant-cachier") |
| 142 | config.cache.scope = :box |
| 143 | end |
| 144 | |
| 145 | end |