forked from Xeus-Territory/kubewekend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile.ceph
More file actions
57 lines (49 loc) · 2.06 KB
/
Vagrantfile.ceph
File metadata and controls
57 lines (49 loc) · 2.06 KB
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
Vagrant.configure("2") do |config|
# # Handle multiple machine in one block of Vagrantfile
# # https://developer.hashicorp.com/vagrant/docs/multi-machine
config.vm.define "k8s-master-machine", primary: true do |config|
config.vm.box = "ubuntu/focal64"
config.vm.hostname = "k8s-master-machine"
config.vm.communicator = "ssh"
# Default enable 2222 for ssh communication (Add id: "ssh" to disable default)
# https://realguess.net/2015/10/06/overriding-the-default-forwarded-ssh-port-in-vagrant/
config.vm.network "forwarded_port", guest: 22, host: 6996, protocol: "tcp", id: "ssh", host_ip: "127.0.0.1"
config.vm.box_check_update = false
config.ssh.username = ENV["SSH_USER"]
config.ssh.private_key_path = ENV["SSH_PRIV_KEY_PATH"]
config.ssh.port = 6996
config.ssh.guest_port = 22
# # Disable to generate a key pair inside .vargrant directory, use insecure_private_keys
# # instead of using private_key
# config.ssh.insert_key = false
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |config|
config.name = "k8s-master-machine"
# Change here when you need more memory to prevent Errors: 137 in Kubernetes
config.memory = 4092
config.cpus = 2
end
# Add one more disk 10GB for master node, use for ceph prerequisites
config.vm.disk :disk, size: "10GB", name: "extra_storage"
end
# Initialize the shell command to configuration
$configScript = <<-'SHELL'
sudo -i
sudo apt update && sudo apt install curl git -y
sudo apt install docker.io docker-compose -y
sudo usermod -aG docker vagrant
SHELL
# Reload profile of current user on machine
$reloadProfile = <<-'SHELL'
sudo -i
shutdown -r now
SHELL
# Execution the shell script provide
config.vm.provision "shell", inline: $configScript
# Configuration auto trigger reload profile in machine after shell
config.trigger.after :up, :provision do |trigger|
trigger.info = "Running a after trigger!"
trigger.run_remote = { inline: $reloadProfile }
trigger.ignore = [:destroy, :halt]
end
end