-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
59 lines (51 loc) · 1.66 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
box = "ubuntu/jammy64"
N = 2
common_script = <<~SHELL
export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt upgrade -y
SHELL
Vagrant.configure("2") do |config|
config.vm.define "lb" do |node|
node.vm.box = box
node.vm.network :private_network, ip: "192.168.56.100", hostname: true
node.vm.network "forwarded_port", guest: 6443, host: 6443
node.vm.hostname = "lb.local"
node.vm.provider "virtualbox" do |vb|
vb.name = "k8s-the-hard-way-lb"
vb.memory = "1024"
vb.cpus = 1
vb.linked_clone = true
end
node.vm.synced_folder "share/dl", "/downloads", create: true
node.vm.provision "shell", inline: common_script
node.vm.provision "ansible" do |ansible|
ansible.verbose = "vv"
ansible.playbook = "bootstrap.yml"
ansible.compatibility_mode = "2.0"
end
end
(0..N).each do |machine_id|
config.vm.define "node#{machine_id}" do |node|
node.vm.box = box
node.vm.hostname = "node#{machine_id}.local"
node.vm.network :private_network, ip: "192.168.56.#{machine_id+2}", hostname: true
node.vm.provider "virtualbox" do |vb|
vb.name = "k8s-the-hard-way-node#{machine_id}"
vb.memory = "1024"
vb.cpus = 1
vb.linked_clone = true
end
# To hold the downloaded items and survive VM restarts
node.vm.synced_folder "share/dl", "/downloads", create: true
node.vm.provision "shell", inline: common_script
if machine_id == N
node.vm.provision :ansible do |ansible|
ansible.limit = "all"
ansible.verbose = "vv"
ansible.playbook = "bootstrap.yml"
end
end
end
end
end