-
Notifications
You must be signed in to change notification settings - Fork 10
/
Vagrantfile
58 lines (47 loc) · 2.35 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
machine_name = "appserver.test"
ip_address = "192.168.168.168"
vm_box = "bento/ubuntu-18.04"
Vagrant.configure("2") do |config|
#Machine name for Vagrant, and machine type
config.vm.define machine_name
config.vm.box = vm_box
#Machine name for virtualbox, and RAM size
config.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm", :id,
"--name", "#{machine_name}-docker-AEGEE",
"--memory", "2048",
]
end
# Avoids wasting time on virtualbox guest additions mismatch
config.vbguest.auto_update = false
## Network configurations ##
config.vm.hostname = machine_name
config.vm.network :private_network, ip: ip_address
## Port forwarding
#NOTE: there could be a different script that sets the resolv.conf and then
# calls vagrant up
#If you want to SSH from anywhere on the network (sshd) uncomment this
#config.vm.network :forwarded_port, guest: 22, host: 2222, host_ip: "127.0.0.1", id: "ssh", auto_correct: true
#In case somebody does not use "appserver" but "localhost" uncomment this
#config.vm.network :forwarded_port, guest: 80, host: 8888, id: "main", auto_correct: true
## Provisioning scripts ##
#make it work also when windows messes up the line ending
config.vm.provision "shell", inline: "apt-get install dos2unix -qq -y; cd /vagrant && dos2unix *.sh; dos2unix scripts-vagrant_provision/*.sh"
#nice-to-have prompt and completion
config.vm.provision "shell", inline: "dos2unix /vagrant/scripts-vagrant_provision/bashrc; cat /vagrant/scripts-vagrant_provision/bashrc > /home/vagrant/.bashrc"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "scripts-vagrant_provision/provision.yml"
ansible.compatibility_mode = "2.0"
ansible.extra_vars = "scripts-vagrant_provision/local.yml"
#ansible.tags = "docker"
end
#provision docker orchestration (set to always run)
config.vm.provision "shell", path: "scripts-vagrant_provision/orchestrate_docker.sh", run: "always"
config.vm.post_up_message = "[FINALLY!] Setup is complete, open your browser to http://my.#{machine_name} (did you configure /etc/hosts via start.sh or manually?)"
## Deprovisioning scripts ##
config.trigger.before :destroy do |trigger|
trigger.warn = "Removing .init to avoid Docker network mismatch"
trigger.run_remote = { inline: "rm /vagrant/.init 2>/dev/null || echo 'file already gone'" }
end
end