-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
86 lines (68 loc) · 2.89 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ####################################################################
# ################### CONFIGURATION VARIABLES ########################
# ####################################################################
IMAGE_NAME = "bento/ubuntu-18.04" # Image to use
MEM = 4096 # Amount of RAM
CPU = 2 # Number of processors (Minimum value of 2 otherwise it will not work)
MASTER_NAME="master" # Master node name
WORKER_NBR = 4 # Number of workers node
NODE_NETWORK_BASE = "192.168.56" # First three octets of the IP address that will be assign to all type of nodes
POD_NETWORK = "10.244.0.0/16" # Private network for inter-pod communication
# ######################## START VAGRANT #############################
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
# RAM and CPU config
config.vm.provider "virtualbox" do |v|
v.memory = MEM
v.cpus = CPU
end
# Master node config
config.vm.define MASTER_NAME do |master|
# Hostname and network config
master.vm.box = IMAGE_NAME
master.vm.network "private_network", ip: "#{NODE_NETWORK_BASE}.10"
master.vm.hostname = MASTER_NAME
# Ansible role setting
master.vm.provision "ansible" do |ansible|
# Add debug mode
#ansible.verbose = "vvv"
ansible.compatibility_mode = "2.0"
# Ansbile role that will be launched
ansible.playbook = "roles/main.yml"
# Groups in Ansible inventory
ansible.groups = {
"masters" => ["#{MASTER_NAME}"],
"workers" => ["worker-[1:#{WORKER_NBR}]"]
}
# Overload Ansible variables
ansible.extra_vars = {
node_ip: "#{NODE_NETWORK_BASE}.10",
node_name: "master",
pod_network: "#{POD_NETWORK}"
}
end
end
# Worker node config
(1..WORKER_NBR).each do |i|
config.vm.define "worker-#{i}" do |worker|
# Hostname and network config
worker.vm.box = IMAGE_NAME
worker.vm.network "private_network", ip: "#{NODE_NETWORK_BASE}.#{i + 10}"
worker.vm.hostname = "worker-#{i}"
# Ansible role setting
worker.vm.provision "ansible" do |ansible|
# Ansible role that will be launched
ansible.playbook = "roles/main.yml"
# Groups in Ansible inventory
ansible.groups = {
"masters" => ["#{MASTER_NAME}"],
"workers" => ["worker-[1:#{WORKER_NBR}]"]
}
# Overload Ansible variables
ansible.extra_vars = {
node_ip: "#{NODE_NETWORK_BASE}.#{i + 10}"
}
end
end
end
end