-
Notifications
You must be signed in to change notification settings - Fork 3
/
Vagrantfile
57 lines (48 loc) · 2.06 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
$logger = Log4r::Logger.new('vagrantfile')
def read_ip_address(machine)
command = "ip -o addr show dev enp0s8 | grep 'inet ' | cut -d: -f2 | awk '{ print $3 }' | cut -f1 -d\"/\""
result = ""
$logger.info "Processing #{ machine.name } ... "
begin
# sudo is needed for ifconfig
machine.communicate.sudo(command) do |type, data|
result << data if type == :stdout
end
$logger.info "Processing #{ machine.name } ... success"
rescue
result = "# NOT-UP"
$logger.info "Processing #{ machine.name } ... not running"
end
# the second inet is more accurate
result.chomp.split("\n").select { |hash| hash != "" }[0]
end
Vagrant.configure("2") do |config|
# This code fail with Virtualbox 6, then I comment it
# config.vm.provider :virtualbox do |vb|
# vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ] # to disable ubuntu-*-cloudimg-console.log
# end
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
if Vagrant.has_plugin?("HostManager")
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
read_ip_address(vm)
end
end
config.vm.define :gitlab_server do |gitlab_server|
gitlab_server.vm.box = "ubuntu/focal64"
#gitlab_server.disksize.size = "150GB" # uncomment this line if you want to increase the disk size
gitlab_server.vm.hostname = "gitlab"
gitlab_server.vm.synced_folder '.', '/vagrant/', disabled: false
gitlab_server.vm.network "private_network", type: "dhcp"
gitlab_server.hostmanager.aliases = ["gitlab.example.com", "registry.example.com"]
gitlab_server.vm.provider :virtualbox do |vb|
vb.memory = '8024'
vb.cpus = '1'
end
gitlab_server.vm.provision "shell", path: "install.sh"
gitlab_server.vm.provision "shell", path: "expose-gitlab-ssh-port.sh", env: {"GIT_UID_IN_HOST" => "1010"}
gitlab_server.vm.provision "shell", inline: "cd /vagrant && docker compose up -d gitlab --wait"
gitlab_server.vm.provision "shell", inline: "cd /vagrant/nginx-proxy/ && docker compose up -d"
end
end