@@ -8,14 +8,12 @@ gopath_folder="/opt/gopath"
8
8
9
9
cluster_ip_nodes = ""
10
10
11
- provision_common = <<SCRIPT
11
+ provision_common_once = <<SCRIPT
12
12
## setup the environment file. Export the env-vars passed as args to 'vagrant up'
13
13
echo Args passed: [[ $@ ]]
14
14
echo -n "$1" > /etc/hostname
15
15
hostname -F /etc/hostname
16
- /sbin/ip addr add "$2/24" dev eth1
17
- /sbin/ip link set eth1 up
18
- /sbin/ip link set eth2 up
16
+
19
17
echo 'export GOPATH=#{ gopath_folder } ' > /etc/profile.d/envvar.sh
20
18
echo 'export GOBIN=$GOPATH/bin' >> /etc/profile.d/envvar.sh
21
19
echo 'export GOSRC=$GOPATH/src' >> /etc/profile.d/envvar.sh
@@ -32,15 +30,8 @@ if [[ $# -gt 9 ]] && [[ $10 != "" ]]; then
32
30
echo "export $@" >> /etc/profile.d/envvar.sh
33
31
fi
34
32
35
- # Enable ovs mgmt port
36
- (ovs-vsctl set-manager tcp:127.0.0.1:6640 && \
37
- ovs-vsctl set-manager ptcp:6640) || exit 1
38
-
39
- # Drop cache to workaround vboxsf problem
40
- echo 3 > /proc/sys/vm/drop_caches
41
-
42
- # Change ownership for gopath folder
43
- chown vagrant #{ gopath_folder }
33
+ # Change ownership for gopath folder
34
+ chown vagrant #{ gopath_folder }
44
35
45
36
# Install specific docker version if required
46
37
if [[ $8 != "" ]]; then
@@ -65,7 +56,7 @@ cp #{gopath_folder}/src/github.com/contiv/netplugin/scripts/docker-tcp.socket /e
65
56
systemctl enable docker-tcp.socket
66
57
mkdir /etc/systemd/system/docker.service.d
67
58
echo "[Service]" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
68
- echo "Environment=\\ \" no_proxy=$3 ,127.0.0.1,localhost,netmaster\\ \" \\ \" http_proxy=$http_proxy\\ \" \\ \" https_proxy=$https_proxy\\ \" " | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
59
+ echo "Environment=\\ \" no_proxy=$CLUSTER_NODE_IPS ,127.0.0.1,localhost,netmaster\\ \" \\ \" http_proxy=$http_proxy\\ \" \\ \" https_proxy=$https_proxy\\ \" " | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
69
60
sudo systemctl daemon-reload
70
61
sudo systemctl stop docker
71
62
systemctl start docker-tcp.socket
@@ -79,6 +70,19 @@ docker load --input #{gopath_folder}/src/github.com/contiv/netplugin/scripts/dns
79
70
80
71
SCRIPT
81
72
73
+ provision_common_always = <<SCRIPT
74
+ /sbin/ip addr add "$2/24" dev eth1
75
+ /sbin/ip link set eth1 up
76
+ /sbin/ip link set eth2 up
77
+
78
+ # Drop cache to workaround vboxsf problem
79
+ echo 3 > /proc/sys/vm/drop_caches
80
+
81
+ # Enable ovs mgmt port
82
+ (ovs-vsctl set-manager tcp:127.0.0.1:6640 && \
83
+ ovs-vsctl set-manager ptcp:6640) || exit 1
84
+ SCRIPT
85
+
82
86
provision_gobgp = <<SCRIPT
83
87
#Get gobgp binary
84
88
wget https://cisco.box.com/shared/static/5leqlo84kjh0thty91ouotilm4ish3nz -q -O #{ gopath_folder } /bin/gobgp && chmod +x #{ gopath_folder } /bin/gobgp
@@ -92,6 +96,7 @@ echo "export https_proxy='$2'" >> /etc/profile.d/envvar.sh
92
96
source /etc/profile.d/envvar.sh
93
97
SCRIPT
94
98
99
+
95
100
VAGRANTFILE_API_VERSION = "2"
96
101
Vagrant . configure ( VAGRANTFILE_API_VERSION ) do |config |
97
102
if ENV [ 'CONTIV_NODE_OS' ] && ENV [ 'CONTIV_NODE_OS' ] == "ubuntu" then
@@ -108,6 +113,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
108
113
num_nodes = ENV [ 'CONTIV_NODES' ] . to_i
109
114
end
110
115
base_ip = "192.168.2."
116
+ if ENV [ 'CONTIV_IP_PREFIX' ] && ENV [ 'CONTIV_IP_PREFIX' ] != "" then
117
+ base_ip = ENV [ 'CONTIV_IP_PREFIX' ]
118
+ end
111
119
node_ips = num_nodes . times . collect { |n | base_ip + "#{ n +10 } " }
112
120
cluster_ip_nodes = node_ips . join ( "," )
113
121
@@ -118,7 +126,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
118
126
119
127
quagga1 . vm . box = "contiv/quagga1"
120
128
quagga1 . vm . host_name = "quagga1"
121
- quagga1 . vm . network :private_network , ip : "192.168.1.50 ", virtualbox__intnet : "true" , auto_config : false
129
+ quagga1 . vm . network :private_network , ip : base_ip + "51 ", virtualbox__intnet : "true" , auto_config : false
122
130
quagga1 . vm . network "private_network" ,
123
131
ip : "80.1.1.200" ,
124
132
virtualbox__intnet : "contiv_orange"
@@ -134,7 +142,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
134
142
135
143
quagga2 . vm . box = "contiv/quagga2"
136
144
quagga2 . vm . host_name = "quagga2"
137
- quagga2 . vm . network :private_network , ip : "192.168.1.50 ", virtualbox__intnet : "true" , auto_config : false
145
+ quagga2 . vm . network :private_network , ip : base_ip + "52 ", virtualbox__intnet : "true" , auto_config : false
138
146
quagga2 . vm . network "private_network" ,
139
147
ip : "70.1.1.1" ,
140
148
virtualbox__intnet : "contiv_blue"
@@ -215,14 +223,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
215
223
s . inline = "echo '#{ node_ips [ 0 ] } netmaster' >> /etc/hosts; echo '#{ node_addr } #{ node_name } ' >> /etc/hosts"
216
224
end
217
225
node . vm . provision "shell" do |s |
218
- s . inline = provision_common
226
+ s . inline = provision_common_once
219
227
s . args = [ node_name , node_addr , cluster_ip_nodes , ENV [ "http_proxy" ] || "" , ENV [ "https_proxy" ] || "" , ENV [ "USE_RELEASE" ] || "" , ENV [ "CONTIV_CLUSTER_STORE" ] || "etcd://localhost:2379" , ENV [ "CONTIV_DOCKER_VERSION" ] || "" , ENV [ 'CONTIV_NODE_OS' ] || "" , *ENV [ 'CONTIV_ENV' ] ]
220
228
end
221
229
if ENV [ 'CONTIV_L3' ] then
222
230
node . vm . provision "shell" do |s |
223
231
s . inline = provision_gobgp
224
232
end
225
233
end
234
+ node . vm . provision "shell" , run : "always" do |s |
235
+ s . inline = provision_common_always
236
+ s . args = [ node_name , node_addr ]
237
+ end
238
+
226
239
provision_node = <<SCRIPT
227
240
## start etcd with generated config
228
241
set -x
0 commit comments