-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVagrantfile
More file actions
60 lines (51 loc) · 2 KB
/
Copy pathVagrantfile
File metadata and controls
60 lines (51 loc) · 2 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
58
59
60
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# forks: mysql, mariadb ou percona
# memory, cpus, fork and sample are optional, defaults do:
# 1024, 2, mysql and 0 respectively
vms = {
'db1' => {'ip' => '10', 'box' => 'debian', 'script' => 'debian.sh'},
'db2' => {'ip' => '20', 'box' => 'debian', 'script' => 'debian.sh'},
'db3' => {'ip' => '30', 'box' => 'debian', 'script' => 'debian.sh'},
'haproxy' => {'memory' => 256, 'cpus' => 1, 'ip' => '40', 'box' => 'debian', 'script' => 'haproxy.sh'},
'monitor' => {'cpus' => 2, 'memory' => 2048, 'ip' => '50', 'box' => 'debian', 'script' => 'debian.sh'},
'rhel-demo' => {'ip' => '60', 'box' => 'alma', 'script' => 'rhel.sh'}
}
resources = {
'cpus' => 2,
'memory' => 1024
}
# Boxes: https://portal.cloud.hashicorp.com/vagrant/discover
boxes = {
'debian' => 'debian/bookworm64',
'centos' => 'centos/stream9',
'rocky' => 'rockylinux/9',
'alma' => 'almalinux/9'
}
Vagrant.configure('2') do |config|
# Desativa verificação automatica de atualização do BOX a cada vagrant up.
config.vm.box_check_update = false
# Necessário instalar o plugin: vagrant plugin install vagrant-disksize
# config.disksize.size = '10GB'
# Virtualbox
vms.each do |name, conf|
config.vm.define "#{name}" do |my|
args = [conf['fork'] || 'mysql', conf['sample'] || 0]
my.vm.box = boxes[conf['box']]
my.vm.hostname = "#{name}.example.com"
my.vm.network 'private_network', ip: "172.27.11.#{conf['ip']}"
my.vm.provision 'shell', path: "provision/#{conf['script']}", args: args
my.vm.provider 'virtualbox' do |vb|
vb.memory = conf['memory'] || resources['memory']
vb.cpus = conf['cpus'] || resources['cpus']
end
# libvirt
my.vm.provider 'libvirt' do |lv|
lv.memory = conf['memory'] || resources['memory']
lv.cpus = conf['cpus'] || resources['cpus']
lv.cputopology :sockets => 1, :cores => conf['cpus'] || resources['cpus'], :threads => '1'
end
end
end
end