-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
134 lines (105 loc) · 4 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Para aprovechar este Vagrantfile necesita Vagrant y Virtualbox instalados:
#
# * Virtualbox
#
# * Vagrant
#
# * Plugins de Vagrant:
# + vagrant-proxyconf y su configuracion si requiere de un Proxy para salir a Internet
# + vagrant-cachier
# + vagrant-disksize
# + vagrant-share
# + vagrant-vbguest
VAGRANTFILE_API_VERSION = "2"
DOMAIN = "infra.ballardini.com.ar"
NODE_COUNT = 3
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.auto_detect = false
# W: Download is performed unsandboxed as root as file '/var/cache/apt/archives/partial/xyz' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
config.cache.synced_folder_opts = {
owner: "_apt"
}
# Configure cached packages to be shared between instances of the same base box.
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :box
end
(1..NODE_COUNT).each do |nodo|
config.vm.define "lxd#{nodo}" do |srv|
srv.vm.box = "ubuntu/focal64"
srv.vm.network "private_network", ip: "192.168.33.1#{nodo}"
srv.vm.boot_timeout = 3600
srv.vm.box_check_update = true
srv.ssh.forward_agent = true
srv.ssh.forward_x11 = true
srv.vm.hostname = "lxd#{nodo}"
if Vagrant.has_plugin?("vagrant-vbguest") then
srv.vbguest.auto_update = true
srv.vbguest.no_install = false
end
srv.vm.synced_folder ".", "/vagrant", disabled: false, SharedFoldersEnableSymlinksCreate: false
srv.vm.provider :virtualbox do |vb|
vb.gui = false
vb.cpus = 2
vb.memory = "2048"
vb.customize ["modifyvm", :id, "--nested-hw-virt", "on"]
# https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm mas parametros para personalizar en VB
end
srv.vm.provision "instala_lxd", type: "shell" do |s|
s.privileged = false
s.path = "provision/instala-lxd.sh"
end
end
end # nodos del cluster
config.vm.define "workstation", autostart: false do |cliente|
cliente.vm.box = "ubuntu/focal64"
cliente.vm.network "private_network", ip: "192.168.33.10"
cliente.vm.boot_timeout = 3600
cliente.vm.box_check_update = true
cliente.ssh.forward_agent = true
cliente.ssh.forward_x11 = true
cliente.vm.hostname = "workstation"
if Vagrant.has_plugin?("vagrant-vbguest") then
cliente.vbguest.auto_update = true
cliente.vbguest.no_install = false
end
cliente.vm.synced_folder ".", "/vagrant", disabled: false, SharedFoldersEnableSymlinksCreate: false
cliente.vm.provider :virtualbox do |vb|
vb.gui = false
vb.cpus = 2
vb.memory = "1024"
# https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm mas parametros para personalizar en VB
end
cliente.vm.provision "instala_ws", type: "shell" do |s|
s.privileged = false
s.path = "provision/instala-ws.sh"
end
end
##
# Provisioning para todas las VM (esto corre antes que el provisioning de cada una)
#
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
config.vm.provision "actualiza", type: "shell" do |s| # http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
s.privileged = false
s.path = "provision/actualiza.sh"
end
config.vm.provision "ssh_pub_key", type: :shell do |s|
begin
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
s.inline = <<-SHELL
mkdir -p /root/.ssh/
touch /root/.ssh/authorized_keys
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
SHELL
rescue
puts "No hay claves publicas en el HOME de su pc"
s.inline = "echo OK sin claves publicas"
end
end
end