-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision.rb
36 lines (28 loc) · 1.06 KB
/
provision.rb
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
module Provision
def provision_node(config, cluster, role, box_type)
setup = cluster[role]
setup[:nodes].each_with_index do |node, index|
config.vm.define node[:id] do |machine|
machine.vm.box = setup[:box][box_type]
machine.vm.provider "virtualbox" do |vb|
vb.cpus = setup[:cpu]
vb.memory = setup[:memory]
end
machine.vm.hostname = node[:hostname]
machine.vm.network "private_network", ip: node[:ip]
if index == setup[:nodes].length - 1
machine.vm.provision "ansible" do |ansible|
ansible.playbook = setup[:ansible][:playbook][box_type]
ansible.limit = setup[:ansible][:limit]
ansible.extra_vars = {
k8s_cluster_nodes: cluster[:master][:nodes] + cluster[:worker][:nodes],
k8s_cluster_dns_server: cluster[:dnsserver],
k8s_cluster_nfs_server: cluster[:nfsserver],
k8s_cluster_load_balancer: cluster[:loadbalancer]
}
end
end
end
end
end
end