-
Notifications
You must be signed in to change notification settings - Fork 98
/
Vagrantfile
64 lines (59 loc) · 2.29 KB
/
Vagrantfile
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
os_type = (ENV['OS_TYPE'] || "centos").downcase
case os_type
when "centos"
Vagrant.configure(2) do |config|
(1..3).each do |i|
nodename = "node#{i}"
config.vm.define nodename, primary: i == 1, autostart: i == 1 do |node|
node.vm.box = "laincloud/centos-lain"
node.vm.hostname = nodename
node.vm.provider "virtualbox" do |v|
v.memory = i == 1 ? 1536 : 768
end
if i == 1
node.vm.provision "shell",
inline: "sudo /vagrant/bootstrap "\
"-m https://l2ohopf9.mirror.aliyuncs.com "\
"-r docker.io/laincloud --vip=192.168.77.201"
end
node.vm.network "private_network", ip: "192.168.77.2#{i}"
end
end
end
when "ubuntu"
ENV["LC_ALL"] = "C"
unless Vagrant.has_plugin?("vagrant-disksize")
puts "please install disksize plugin first."
puts "cmd: vagrant plugin install vagrant-disksize"
raise "vagrant-disksize is not isntalled."
end
Vagrant.configure(2) do |config|
(1..3).each do |i|
nodename = "node#{i}"
config.vm.define nodename, primary: i == 1, autostart: i == 1 do |node|
node.vm.box = "ubuntu/xenial64"
node.vm.hostname = nodename
node.disksize.size = '30GB'
node.vm.provider "virtualbox" do |v|
v.memory = i == 1 ? 1536 : 768
end
if i == 1
node.vm.provision "shell",
inline: "sudo python3 /vagrant/bootstrap "\
"-m https://l2ohopf9.mirror.aliyuncs.com "\
"-r docker.io/laincloud --vip=192.168.77.201"
else
node.vm.provision "shell",
inline: "sed -i 's/^PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config && "\
"systemctl restart sshd &&" \
"echo 'root:vagrant' | chpasswd &&" \
"sed -i s/archive.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && " \
"apt update && apt install -y python"
end
node.vm.network "private_network", ip: "192.168.77.2#{i}"
end
end
end
else
puts "invalid os type"
end