Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
David K. Bainbridge | a0a36e9 | 2016-10-13 18:05:33 -0700 | [diff] [blame] | 4 | # Look at the command line arguments and the environment to |
| 5 | # determine the provider being used |
| 6 | if ARGV[1] and (ARGV[1].split('=')[0] == "--provider" or ARGV[2]) |
| 7 | provider = (ARGV[1].split('=')[1] || ARGV[2]) |
| 8 | else |
| 9 | provider = (ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym |
| 10 | end |
| 11 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 12 | Vagrant.configure(2) do |config| |
| 13 | |
| 14 | if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 15 | config.vm.synced_folder "..", "/cord", mount_options: ["dmode=700,fmode=600"] |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 16 | else |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 17 | config.vm.synced_folder "..", "/cord" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 18 | end |
| 19 | |
| 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" |
| 23 | d.vm.hostname = "corddev" |
| 24 | d.vm.network "private_network", ip: "10.100.198.200" |
David K. Bainbridge | 0bdec19 | 2016-10-13 18:10:10 -0700 | [diff] [blame^] | 25 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
| 26 | 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] | 27 | d.vm.provider "virtualbox" do |v| |
| 28 | v.memory = 2048 |
| 29 | end |
David K. Bainbridge | a0a36e9 | 2016-10-13 18:05:33 -0700 | [diff] [blame] | 30 | |
| 31 | # The libvirt provider is not handling mounts "normally", so for now get the source into the VM |
| 32 | # via an rsync |
| 33 | if provider == "libvirt" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 34 | d.vm.synced_folder '../', '/cord', type: 'rsync', rsync__args: ["--verbose", "--archive", "--delete", "-z"] |
| 35 | d.vm.synced_folder '.', '/vagrant', type: 'rsync', disabled: true |
David K. Bainbridge | a0a36e9 | 2016-10-13 18:05:33 -0700 | [diff] [blame] | 36 | d.vm.provider :libvirt do |domain| |
| 37 | domain.memory = 2048 |
| 38 | end |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 39 | end |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 40 | end |
| 41 | |
| 42 | config.vm.define "prod" do |d| |
| 43 | d.vm.box = "ubuntu/trusty64" |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 44 | d.vm.synced_folder '.', '/vagrant', disable: true |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 45 | d.vm.hostname = "prod" |
| 46 | d.vm.network "private_network", ip: "10.100.198.201" |
David K. Bainbridge | 6f2cbe7 | 2016-08-19 15:48:07 -0700 | [diff] [blame] | 47 | d.vm.network "private_network", ip: "0.0.0.0", virtualbox__intnet: "cord-test-network" |
| 48 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 49 | 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] | 50 | d.vm.provider "virtualbox" do |v| |
David K. Bainbridge | 97b3f2f | 2016-06-16 18:08:49 -0700 | [diff] [blame] | 51 | v.memory = 2048 |
| 52 | end |
| 53 | end |
| 54 | |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 55 | config.vm.define "switch" do |s| |
| 56 | s.vm.box = "ubuntu/trusty64" |
| 57 | s.vm.hostname = "fakeswitch" |
| 58 | s.vm.network "private_network", ip: "10.100.198.253" |
| 59 | s.vm.network "private_network", |
| 60 | type: "dhcp", |
| 61 | virtualbox__intnet: "cord-test-network", |
| 62 | mac: "cc37ab000001" |
| 63 | s.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
alshabib | b6ae086 | 2016-08-26 10:55:48 -0700 | [diff] [blame] | 64 | 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] | 65 | s.vm.provider "virtualbox" do |v| |
David K. Bainbridge | 97b3f2f | 2016-06-16 18:08:49 -0700 | [diff] [blame] | 66 | v.memory = 1048 |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 67 | v.name = "fakeswitch" |
| 68 | end |
| 69 | end |
| 70 | |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 71 | config.vm.define "testbox" do |d| |
| 72 | d.vm.box = "fgrehm/trusty64-lxc" |
| 73 | d.ssh.forward_agent = true |
| 74 | d.vm.hostname = "testbox" |
| 75 | d.vm.network "private_network", ip: "10.0.3.100", lxc__bridge_name: 'lxcbr0' |
| 76 | d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh" |
| 77 | d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/corddev.yml -c local" |
| 78 | config.vm.provider :lxc do |lxc| |
| 79 | # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox |
| 80 | lxc.customize 'cgroup.memory.limit_in_bytes', '2048M' |
alshabib | 270d766 | 2016-09-06 14:09:18 -0700 | [diff] [blame] | 81 | lxc.customize 'aa_profile', 'unconfined' |
| 82 | lxc.customize 'cgroup.devices.allow', 'b 7:* rwm' |
| 83 | lxc.customize 'cgroup.devices.allow', 'c 10:237 rwm' |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 84 | end |
David K. Bainbridge | a0a36e9 | 2016-10-13 18:05:33 -0700 | [diff] [blame] | 85 | end |
alshabib | cb8e09b | 2016-09-06 11:41:29 -0700 | [diff] [blame] | 86 | |
David K. Bainbridge | d506aa6 | 2016-06-22 16:06:39 -0700 | [diff] [blame] | 87 | (1..3).each do |i| |
| 88 | # Defining VM properties |
| 89 | config.vm.define "compute_node#{i}" do |c| |
| 90 | c.vm.box = "clink15/pxe" |
| 91 | c.vm.synced_folder '.', '/vagrant', disable: true |
| 92 | c.vm.communicator = "none" |
| 93 | c.vm.hostname = "computenode" |
| 94 | c.vm.network "private_network", |
| 95 | adapter: "1", |
| 96 | type: "dhcp", |
| 97 | auto_config: false, |
| 98 | virtualbox__intnet: "cord-test-network" |
| 99 | c.vm.provider "virtualbox" do |v| |
| 100 | v.name = "compute_node#{i}" |
| 101 | v.memory = 1048 |
| 102 | v.gui = "true" |
| 103 | end |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 104 | end |
| 105 | end |
| 106 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 107 | # Libvirt compute node |
| 108 | # Not able to merge with virtualbox config for compute nodes above |
| 109 | # Issue is that here no box and no private network are specified |
| 110 | config.vm.define "compute_node" do |c| |
| 111 | c.vm.synced_folder '.', '/vagrant', disable: true |
| 112 | c.vm.communicator = "none" |
| 113 | c.vm.hostname = "computenode" |
| 114 | c.vm.network "public_network", |
| 115 | adapter: 1, |
| 116 | auto_config: false, |
| 117 | dev: "mgmtbr", |
| 118 | mode: "bridge", |
| 119 | type: "bridge" |
| 120 | c.vm.provider :libvirt do |domain| |
| 121 | domain.memory = 8192 |
| 122 | domain.cpus = 4 |
| 123 | domain.machine_virtual_size = 100 |
| 124 | domain.storage :file, :size => '100G', :type => 'qcow2' |
| 125 | domain.boot 'network' |
| 126 | domain.boot 'hd' |
| 127 | domain.nested = true |
| 128 | end |
| 129 | end |
| 130 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 131 | if Vagrant.has_plugin?("vagrant-cachier") |
| 132 | config.cache.scope = :box |
| 133 | end |
| 134 | |
| 135 | end |