-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
77 lines (55 loc) · 1.85 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
Vagrant.configure("2") do |config|
###################################################################################
# define number of agents
W = 1
# provision W VMs as agents
(1..W).each do |i|
# name the VMs
config.vm.define "k3sagent#{i}" do |node|
# which image to use
node.vm.box = "opensuse/Leap-15.2.x86_64"
# sizing of the VMs
node.vm.provider "libvirt" do |lv|
lv.random_hostname = true
lv.memory = 1024
lv.cpus = 2
end
# set the hostname
node.vm.hostname = "k3sagent#{i}"
end # config.vm.define agents
end # each-loop agents
###############################################
# define number of servers
M = 3
# provision N VMs as servers
(1..M).each do |i|
# name the VMs
config.vm.define "k3sserver#{i}" do |node|
# which image to use
node.vm.box = "opensuse/Leap-15.2.x86_64"
# sizing of the VMs
node.vm.provider "libvirt" do |lv|
lv.random_hostname = true
lv.memory = 1024
lv.cpus = 2
end
# set the hostname
node.vm.hostname = "k3sserver#{i}"
# if this is the last machine
if i == M
#################################################
# only target one node to not run ansible twice
# but do not limit this to this node (set ansible.limit to all)
node.vm.provision "ansible" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.limit = "all"
ansible.groups = {
"k3sservers" => [ "k3sserver1", "k3sserver2", "k3sserver3" ],
"k3sagents" => [ "k3sagent1" ]
}
ansible.playbook = "ansible/playbook-vagrant.yml"
end # node.vm.provision
end # if-condition last machine
end # config.vm.define servers
end # each-loop servers
end # Vagrant.configure