blob: 3294e1386cd9260a9bde561ffc8fc14c7b9f8a46 [file] [log] [blame]
Zsolt Harasztiec7df102016-05-05 13:34:18 -07001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
David K. Bainbridgea0a36e92016-10-13 18:05:33 -07004# Look at the command line arguments and the environment to
5# determine the provider being used
6if ARGV[1] and (ARGV[1].split('=')[0] == "--provider" or ARGV[2])
7 provider = (ARGV[1].split('=')[1] || ARGV[2])
8else
9 provider = (ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym
10end
11
Zsolt Harasztiec7df102016-05-05 13:34:18 -070012Vagrant.configure(2) do |config|
13
14 if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
alshabibb6ae0862016-08-26 10:55:48 -070015 config.vm.synced_folder "..", "/cord", mount_options: ["dmode=700,fmode=600"]
Zsolt Harasztiec7df102016-05-05 13:34:18 -070016 else
alshabibb6ae0862016-08-26 10:55:48 -070017 config.vm.synced_folder "..", "/cord"
Zsolt Harasztiec7df102016-05-05 13:34:18 -070018 end
19
20 config.vm.define "corddev" do |d|
Zsolt Haraszti5b5a42a2016-05-12 22:19:57 -070021 d.ssh.forward_agent = true
Zsolt Harasztiec7df102016-05-05 13:34:18 -070022 d.vm.box = "ubuntu/trusty64"
23 d.vm.hostname = "corddev"
24 d.vm.network "private_network", ip: "10.100.198.200"
David K. Bainbridge0bdec192016-10-13 18:10:10 -070025 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 Harasztiec7df102016-05-05 13:34:18 -070027 d.vm.provider "virtualbox" do |v|
28 v.memory = 2048
29 end
David K. Bainbridgea0a36e92016-10-13 18:05:33 -070030
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 Bavier99c11d32016-09-14 17:21:20 -040034 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. Bainbridgea0a36e92016-10-13 18:05:33 -070036 d.vm.provider :libvirt do |domain|
37 domain.memory = 2048
38 end
Andy Bavier99c11d32016-09-14 17:21:20 -040039 end
Zsolt Harasztiec7df102016-05-05 13:34:18 -070040 end
41
42 config.vm.define "prod" do |d|
43 d.vm.box = "ubuntu/trusty64"
David K. Bainbridged506aa62016-06-22 16:06:39 -070044 d.vm.synced_folder '.', '/vagrant', disable: true
Zsolt Harasztiec7df102016-05-05 13:34:18 -070045 d.vm.hostname = "prod"
46 d.vm.network "private_network", ip: "10.100.198.201"
David K. Bainbridge6f2cbe72016-08-19 15:48:07 -070047 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"
alshabibb6ae0862016-08-26 10:55:48 -070049 d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/prod.yml -c local"
Zsolt Harasztiec7df102016-05-05 13:34:18 -070050 d.vm.provider "virtualbox" do |v|
David K. Bainbridge97b3f2f2016-06-16 18:08:49 -070051 v.memory = 2048
52 end
53 end
54
David K. Bainbridged506aa62016-06-22 16:06:39 -070055 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"
alshabibb6ae0862016-08-26 10:55:48 -070064 s.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/fakeswitch.yml -c local"
David K. Bainbridged506aa62016-06-22 16:06:39 -070065 s.vm.provider "virtualbox" do |v|
David K. Bainbridge97b3f2f2016-06-16 18:08:49 -070066 v.memory = 1048
David K. Bainbridged506aa62016-06-22 16:06:39 -070067 v.name = "fakeswitch"
68 end
69 end
70
alshabibcb8e09b2016-09-06 11:41:29 -070071 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'
alshabib270d7662016-09-06 14:09:18 -070081 lxc.customize 'aa_profile', 'unconfined'
82 lxc.customize 'cgroup.devices.allow', 'b 7:* rwm'
83 lxc.customize 'cgroup.devices.allow', 'c 10:237 rwm'
alshabibcb8e09b2016-09-06 11:41:29 -070084 end
David K. Bainbridgea0a36e92016-10-13 18:05:33 -070085 end
alshabibcb8e09b2016-09-06 11:41:29 -070086
David K. Bainbridged506aa62016-06-22 16:06:39 -070087 (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 Harasztiec7df102016-05-05 13:34:18 -0700104 end
105 end
106
Andy Bavier99c11d32016-09-14 17:21:20 -0400107 # 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 Harasztiec7df102016-05-05 13:34:18 -0700131 if Vagrant.has_plugin?("vagrant-cachier")
132 config.cache.scope = :box
133 end
134
135end