-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVagrantfile_multinode
145 lines (111 loc) · 5.14 KB
/
Vagrantfile_multinode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version " > 1.5"
# Note if you run more than one site, you must have a unique site_instance
# for each site (each vbox host must have a unique ip address for it private
# network interface)
$site_instance = 0
$num_hosts = 1
$instance_name_prefix = "host-"
$host_bridge_interface = 'eth1'
#$host_bridge_interface = 'enp3s0'
#$host_bridge_interface = 'en3: Thunderbolt Eithernet'
$registry = "dockerreg.cyanoptics.com"
$registry_user = "superuser"
$registry_password = "superuser"
HOSTREPO_DEBS = [
"openvswitch-common_2.4.0-0ubuntu4_amd64.deb",
"openvswitch-switch_2.4.0-0ubuntu4_amd64.deb",
"bridge-utils_1.5-6ubuntu2_amd64.deb",
]
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu-16.04-virtualbox-17.02-0.3.0-2.2.0.701b072.box"
#config.vm.box_url = "ubuntu/xenial64"
config.ssh.insert_key = false
# Allocate more ram if required for your apps
# Default memory allocation is 2Gb (2048)
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
# If you want to allocate more than one cpu to your VM
# uncomment the following line
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
#HOSTREPO_DEBS.each { |deb|
# config.vm.provision "shell", privileged: false,
# inline: "if [ ! -e #{deb} ]; then fi"
#}
#HOSTREPO_DEBS.each { |deb|
# config.vm.provision "shell",
# inline: "dpkg -i #{deb}"
#}
config.vm.provision "shell", privileged: true,
inline: "apt-get update"
config.vm.provision "shell", privileged: true,
inline: "apt-get install -y python-pip git vim aptitude"
config.vm.provision "shell", privileged: true,
inline: "pip install virtualenv"
config.vm.provision "shell", privileged: false,
inline: "sudo mkdir -p /etc/bp2"
config.vm.provision "shell", privileged: false,
inline: "sudo chown -R vagrant:vagrant /etc/bp2"
config.vm.provision "file", source: "~/.vagrant.d/insecure_private_key", destination: "~/.ssh/id_rsa"
(1..$num_hosts).each do |i|
config.vm.define vm_name = "%s%d" % [$instance_name_prefix, i-1] do |config|
config.vm.hostname = vm_name
#config.vm.network :public_network#, adapter: 4, :bridge=>'eth1'
config.vm.network :public_network, :bridge=>$host_bridge_interface
ip = "192.168.#{42+$site_instance}.#{i+1}"
config.vm.network :private_network, ip: ip
# TODO we need to fix this
(1..$num_hosts).each do |j|
config.vm.provision "shell", privileged: false,
inline: "We need to fix this"
end
# nuke this file to ensure different docker engine IDs / otherwise there is a chance
# we get dup IDs and swarm fails
config.vm.provision "shell",
inline: "rm /etc/docker/key.json"
config.vm.provision "shell", privileged: true,
inline: "mkdir -p /root/.ssh"
config.vm.provision "shell", privileged: true,
inline: "cp -a /home/vagrant/.ssh/* /root/.ssh/."
config.vm.provision "shell", privileged: true,
inline: "chown -R root:root /root/.ssh"
end
end
# Create Host Only network, this is required for NFS mounts to work
# config.vm.network :private_network, ip: "192.168.33.10"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# config.vm.synced_folder ".", "/home/vagrant/Depot", type: "nfs"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
# Enable remote access
# You have to modify hostname if you want to open this machine for remote access
# To allow remote access to the vagrant box you need to create additinal interface
# for bridging, and connect it to eth0 on your host
#
# config.vm.hostname = <<<< MODIFY THIS NAME >>>>
# config.vm.provider :virtualbox do |vb|
# vb.customize ["modifyvm", :id, "--nic4", "bridged"]
# end
# config.vm.network :public_network, adapter: 4, :bridge=>'eth0'
# If you want to share your MAC wireless adapter replace the previous line with
# config.vm.network :public_network, adapter: 4, :bridge => 'en1: Wi-Fi (AirPort)'
# If you want to be able to choose which adapter to use every time vagrant box
# starts replace network configuration line with
# config.vm.network :public_network, adapter: 4
end