This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
56 lines (56 loc) · 1.88 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
Vagrant.configure("2") do |config|
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
CONTROLLERNODES=3
WORKERNODES=3
LBNODES=1
node_name="node"
N = CONTROLLERNODES+WORKERNODES+LBNODES
(1..N).each do |node_id|
if node_id <= N-WORKERNODES-LBNODES
node_name="controller-#{node_id-1}"
ip = "10.240.0.1#{node_id-1}"
memory = "1024"
elsif node_id > N-WORKERNODES-LBNODES && node_id <= N-LBNODES
node_name="worker-#{node_id-1-CONTROLLERNODES}"
ip = "10.240.0.2#{node_id-1-CONTROLLERNODES}"
memory = "512"
else
node_name="loadbalancer-#{node_id-1-CONTROLLERNODES-WORKERNODES}"
ip = "10.240.0.3#{node_id-1-CONTROLLERNODES-WORKERNODES}"
memory = "512"
end
config.vm.define "#{node_name}" do |node|
node.vm.box = "generic/ubuntu2004"
node.vm.provider "libvirt" do |libvirt|
libvirt.memory = "#{memory}"
libvirt.cpus = 2
end
node.vm.provider "virtualbox" do |vb|
vb.memory = "#{memory}"
vb.cpus = 2
end
# node.vm.hostname = "#{node_name}"
node.vm.network "private_network", ip: "#{ip}"
if node_id == N
node.vm.provision :ansible do |ansible|
ansible.groups = {
"controller" => ["controller-[0:#{CONTROLLERNODES-1}]"],
"worker" => ["worker-[0:#{WORKERNODES-1}]"],
"loadbalancer" => ["loadbalancer-[0:#{LBNODES-1}]"],
}
ansible.limit = "all"
ansible.playbook = "provision.yaml"
end
node.vm.provision :ansible do |ansible|
ansible.groups = {
"controller" => ["controller-[0:#{CONTROLLERNODES-1}]"],
"worker" => ["worker-[0:#{WORKERNODES-1}]"],
"loadbalancer" => ["loadbalancer-[0:#{LBNODES-1}]"],
}
ansible.playbook = "plays/site.yaml"
ansible.limit = "all"
end
end
end
end
end