forked from ricardozanini/vagrant-alm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
163 lines (144 loc) · 5.66 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Automatically update VirtualBox guest additions
config.vagrant.plugins = ["vagrant-vbguest"]
config.vbguest.installer_options = {
running_kernel_modules: ["vboxguest"], # https://github.com/dotless-de/vagrant-vbguest/issues/404#issuecomment-768517728
allow_kernel_upgrade: true # https://github.com/dotless-de/vagrant-vbguest/issues/399
}
# Automatically update /etc/hosts for accessing the guests by name
config.vagrant.plugins << "vagrant-hostmanager"
# vagrant up tower --provider virtualbox
config.vm.define "tower", autostart: false do |tower|
tower.vm.hostname = "tower.local"
tower.vm.box = "ansible/tower"
tower.vm.network :private_network, ip: "192.168.56.2"
tower.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 2048
# Nested Virtualization in Virtualbox funktioniert nur mit 1 CPU in den inneren VMs:
# https://www.virtualbox.org/ticket/19561
#v.cpus = 2
v.cpus = 1
end
tower.vm.provider :libvirt do |lb|
lb.memory = 2048
end
end
# Every Vagrant development environment requires a box. You can search for
# boxes at https://app.vagrantup.com/boxes/search
config.vm.box = "ubuntu/focal64"
# give boxes more time to boot - especially required for nested virtualization
config.vm.boot_timeout = 1200
# TODO: let's refactor and build a function for god's sake
config.vm.define "jenkins" do |jenkins|
jenkins.vm.hostname = "jenkins.local"
jenkins.vm.network :private_network, ip: "172.16.10.100"
jenkins.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 2048
end
jenkins.vm.provider :libvirt do |lb|
lb.memory = 2048
end
end
config.vm.define "sonar" do |sonar|
sonar.vm.hostname = "sonar.local"
sonar.vm.network :private_network, ip: "172.16.10.110"
sonar.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 3000
# Nested Virtualization in Virtualbox funktioniert nur mit 1 CPU in den inneren VMs:
# https://www.virtualbox.org/ticket/19561
#v.cpus = 2
v.cpus = 1
end
sonar.vm.provider :libvirt do |lb|
lb.memory = 2048
end
end
config.vm.define "nexus", primary: true do |nexus|
nexus.vm.hostname = "nexus.local"
nexus.vm.network :private_network, ip: "172.16.10.120"
nexus.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 4096
end
nexus.vm.provider :libvirt do |lb|
lb.memory = 4096
end
end
config.vm.define "app", primary: true do |app|
app.vm.hostname = "app.local"
app.vm.network :private_network, ip: "172.16.10.130"
app.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 512
end
app.vm.provider :libvirt do |lb|
lb.memory = 512
end
end
config.vm.define "app2", primary: true do |app2|
app2.vm.hostname = "app2.local"
app2.vm.network :private_network, ip: "172.16.10.140"
app2.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 512
end
app2.vm.provider :libvirt do |lb|
lb.memory = 512
end
end
config.vm.define "ansiblehost", primary: true do |ansiblehost|
ansiblehost.vm.hostname = "ansiblehost.local"
ansiblehost.vm.network :private_network, ip: "172.16.10.190"
ansiblehost.vm.provider :virtualbox do |v|
v.gui = false
v.memory = 768
end
ansiblehost.vm.provider :libvirt do |lb|
lb.memory = 768
end
# Rsync the current folder to /vagrant on ansiblehost
ansiblehost.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__verbose: true
# Create directory for downloading Ansible Roles (to separate them from our own roles)
ansiblehost.vm.provision "shell", privileged: false, inline: "mkdir -p /home/vagrant/ansible-downloads/roles /home/vagrant/ansible-downloads/collections"
# Copy .vagrant directory (excluded from rsync by default)
ansiblehost.vm.provision "file", source: ".vagrant", destination: "/vagrant/.vagrant"
ansiblehost.vm.provision "shell", inline: "chmod og-rwx /vagrant/.vagrant/machines/*/*/private_key"
ansiblehost.vm.provision "ansible_local" do |ansible|
# See alm.yml on how to run the ansible provisioning manually for a specific type of hosts
ansible.playbook = "/vagrant/ansible/alm.yml"
ansible.galaxy_role_file = "/vagrant/ansible/requirements.yml"
ansible.limit = "all"
ansible.inventory_path = "/vagrant/ansible/inventory.ini"
ansible.provisioning_path = "/vagrant/ansible" # required for ansible.cfg
ansible.galaxy_roles_path = "/home/vagrant/ansible-downloads/roles"
ansible.groups = {
"jenkins_server" => ["jenkins"],
"sonar_server" => ["sonar"],
"nexus_server" => ["nexus"],
"app_server" => ["app", "app2"],
}
# For Debugging in case of errors:
# ansible.verbose = "vvv"
end
end
config.vm.provider "libvirt" do |libvirt|
libvirt.storage_pool_name = "ext_storage"
end
if Vagrant.has_plugin?("vagrant-hostmanager")
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
end
end