This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Vagrantfile
299 lines (248 loc) · 12 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# -*- mode: ruby -*-
# vi: set ft=ruby :
# In order to add hosts to virtual box, please run :
# vagrant up
# In order to connect to the server
# ssh [email protected]
# password is vagrant
current_version = Gem::Version.new(Vagrant::VERSION)
windows_version = Gem::Version.new("1.6.0")
hosts_ubuntu = {
"slave01" => "51",
# "slave02" => "52",
# "slave03" => "53",
# "slave03" => "54"
}
hosts_solaris = {
"solaris" => "192.168.34.10",
# "host1" => "192.168.33.11",
# "host2" => "192.168.33.12"
}
HOSTNAME_01 = "slave01"
VAGRANT_BASE_PORT_01 = "51"
VAGRANT_SSH_PORT_01 = "22" + VAGRANT_BASE_PORT_01
VAGRANT_NETWORK_IP_01 = "192.168.11." + VAGRANT_BASE_PORT_01
HOSTNAME_02 = "slave02"
VAGRANT_BASE_PORT_02 = "52"
VAGRANT_SSH_PORT_02 = "22" + VAGRANT_BASE_PORT_02
VAGRANT_NETWORK_IP_02 = "192.168.11." + VAGRANT_BASE_PORT_02
HOSTNAME_03 = "slave03"
VAGRANT_BASE_PORT_03 = "53"
VAGRANT_SSH_PORT_03 = "22" + VAGRANT_BASE_PORT_03
VAGRANT_NETWORK_IP_03 = "192.168.11." + VAGRANT_BASE_PORT_03
HOSTNAME_04 = "slave04"
VAGRANT_BASE_PORT_04 = "54"
VAGRANT_SSH_PORT_04 = "22" + VAGRANT_BASE_PORT_04
VAGRANT_NETWORK_IP_04 = "192.168.11." + VAGRANT_BASE_PORT_04
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
hosts_ubuntu.each do |name, ip|
config.vm.define name do |machine|
#machine.vm.box = "precise32"
##machine.vm.box_url = "http://files.vagrantup.com/precise32.box"
#machine.vm.box_url = "http://download.parallels.com/desktop/vagrant/precise64.box"
#machine.vm.box = "saucy64"
#machine.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-i386-vagrant-disk1.box"
#machine.vm.box_url = "http://download.parallels.com/desktop/vagrant/saucy64.box"
machine.vm.box = "trusty64"
#machine.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box"
machine.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
#machine.vm.box_url = "ubuntu/trusty64"
machine.vm.hostname = "%s.example.org" % name
machine.vm.network :private_network, ip: "192.168.11." + ip
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine.
config.vm.network :forwarded_port, guest: 8080, host: 8080, auto_correct:true
machine.vm.provider "virtualbox" do |v|
v.name = name
v.customize ["modifyvm", :id, "--memory", 1024]
# v.customize ["modifyvm", :id, "--memory", "4096", "--cpus", "4"]
end
#config.vm.provider :libvirt do |libvirt|
#libvirt.driver = "qemu"
#libvirt.host = "example.com"
#libvirt.connect_via_ssh = true
#libvirt.username = "root"
#libvirt.storage_pool_name = "default"
#end
#https://docs.vagrantup.com/v2/provisioning/basic_usage.html
Vagrant::Config.run do |prov|
#prov.vm.provision :shell, :path => "test.sh"
prov.vm.provision_run :always
# :once or :always with :once being the default
end
config.vm.provision "ansible" do |ansible|
#see https://docs.vagrantup.com/v2/provisioning/ansible.html
ansible.playbook = "jenkins-slave-create-image-docker.yml"
ansible.inventory_path = "hosts-vagrant"
ansible.verbose = "vvvv"
ansible.sudo = true
ansible.host_key_checking = false
ansible.extra_vars = { ansible_ssh_user: 'vagrant' }
#ansible.extra_vars = {
# ntp_server: "pool.ntp.org",
# nginx: {
# port: 8008,
# workers: 4
# }
#}
# Disable default limit (required with Vagrant 1.5+)
ansible.limit = 'all'
end
#config.vm.provision "docker" do |docker|
# docker.build_image "/vagrant/app"
#end
#config.vm.provision "docker",
# images: ["ubuntu"]
#end
end
config.vm.define :slave01 do |vagrant|
#vagrant.vm.box = "hfm4/centos5"
vagrant.vm.box = "hfm4/centos6"
#vagrant.vm.box = "hfm4/centos7"
vagrant.vm.boot_timeout = 600
vagrant.vm.hostname = HOSTNAME_01
vagrant.vm.network :private_network, ip: VAGRANT_NETWORK_IP_01
vagrant.vm.provider :virtualbox do |vb|
vb.name = HOSTNAME_01
#vb.customize ["modifyvm", :id, "--memory", "8192"]
vb.memory = 8192
vb.cpus = 4
end
#vagrant.vm.provision "file", source: "../keys/id_rsa", destination: "id_rsa"
#vagrant.vm.provision "file", source: "../keys/id_rsa.pub", destination: "id_rsa.pub"
#vagrant.vm.provision "file", source: "../keys/mgr.jenkins.pub", destination: "mgr.jenkins.pub"
vagrant.vm.provision :shell, :path => "buildup.sh"
#See issue vagrant forward port 22 unable to force
#https://stackoverflow.com/questions/30669183/forwarding-the-ssh-port-fails-when-running-two-vagrant-instances-from-the-same-h
#vagrant.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: "true"
vagrant.vm.network "forwarded_port", guest: 22, host: VAGRANT_SSH_PORT_01, id: 'ssh', auto_correct: "true"
# Generate a random port number
#r = Random.new
#ssh_port = r.rand(1000...5000)
#vagrant.vm.network "forwarded_port", guest: 22, host: "#{ssh_port}", id: 'ssh', auto_correct: true
#vagrant.vm.network "forwarded_port", guest: 8380, host: 8380, auto_correct: true
vagrant.vm.network "forwarded_port", guest: 33224, host: 33224, auto_correct: true
# Do not use a shared folder. We will fetch sources in other ways.
# This allows us (eventually) to export the VM and move it around.
vagrant.vm.synced_folder ".", "/vagrant", disabled: true
#vagrant.ssh.private_key_path = "../keys/id_rsa"
#vagrant.ssh.forward_agent = true
#vagrant.ssh.host = VAGRANT_NETWORK_IP_01
#vagrant.ssh.port = VAGRANT_SSH_PORT_01
#vagrant.ssh.forward_agent = true
#config.vm.provision "ansible" do |ansible|
# #see https://docs.vagrantup.com/v2/provisioning/ansible.html
# ansible.playbook = "../../ansible/jenkins-UAT-slave.yml"
# ansible.inventory_path = "../../ansible/hosts"
# ansible.verbose = "vvvv"
# ansible.sudo = true
# ansible.host_key_checking = false
# ansible.extra_vars = { ansible_ssh_user: 'vagrant' }
# # Disable default limit (required with Vagrant 1.5+)
# ansible.limit = 'all'
#end
end
config.vm.define :slave02 do |vagrant|
#vagrant.vm.box = "hfm4/centos5"
#vagrant.vm.box = "hfm4/centos6"
vagrant.vm.box = "hfm4/centos7"
vagrant.vm.boot_timeout = 600
vagrant.vm.hostname = HOSTNAME_02
vagrant.vm.network :private_network, ip: VAGRANT_NETWORK_IP_02
vagrant.vm.provider :virtualbox do |vb|
vb.name = HOSTNAME_02
#vb.customize ["modifyvm", :id, "--memory", "8192"]
vb.memory = 8192
vb.cpus = 4
end
#vagrant.vm.provision "file", source: "../keys/id_rsa", destination: "id_rsa"
#vagrant.vm.provision "file", source: "../keys/id_rsa.pub", destination: "id_rsa.pub"
#vagrant.vm.provision "file", source: "../keys/mgr.jenkins.pub", destination: "mgr.jenkins.pub"
#vagrant.vm.provision :shell, :path => "buildup.sh"
#See issue vagrant forward port 22 unable to force
#https://stackoverflow.com/questions/30669183/forwarding-the-ssh-port-fails-when-running-two-vagrant-instances-from-the-same-h
#vagrant.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: "true"
vagrant.vm.network "forwarded_port", guest: 22, host: VAGRANT_SSH_PORT_02, id: 'ssh', auto_correct: "true"
vagrant.vm.network "forwarded_port", guest: 33224, host: 33224, auto_correct: true
# Do not use a shared folder. We will fetch sources in other ways.
# This allows us (eventually) to export the VM and move it around.
vagrant.vm.synced_folder ".", "/vagrant", disabled: true
end
config.vm.define :slave03 do |vagrant|
#vagrant.vm.box = "precise32"
##vagrant.vm.box_url = "http://files.vagrantup.com/precise32.box"
#vagrant.vm.box_url = "http://download.parallels.com/desktop/vagrant/precise64.box"
#vagrant.vm.box = "saucy64"
#vagrant.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-i386-vagrant-disk1.box"
#vagrant.vm.box_url = "http://download.parallels.com/desktop/vagrant/saucy64.box"
#vagrant.vm.box = "trusty64"
#vagrant.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box"
#vagrant.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
#vagrant.vm.box_url = "ubuntu/trusty64"
#https://atlas.hashicorp.com/ubuntu/boxes/trusty64
vagrant.vm.box = "ubuntu/trusty64"
#https://atlas.hashicorp.com/ubuntu/boxes/xenial64
#vagrant.vm.box = "ubuntu/xenial64"
vagrant.vm.boot_timeout = 600
vagrant.vm.hostname = HOSTNAME_03
vagrant.vm.network :private_network, ip: VAGRANT_NETWORK_IP_03
vagrant.vm.provider :virtualbox do |vb|
vb.name = HOSTNAME_03
#vb.customize ["modifyvm", :id, "--memory", "8192"]
vb.memory = 8192
vb.cpus = 4
end
#vagrant.vm.provision "file", source: "../keys/id_rsa", destination: "id_rsa"
#vagrant.vm.provision "file", source: "../keys/id_rsa.pub", destination: "id_rsa.pub"
#vagrant.vm.provision "file", source: "../keys/mgr.jenkins.pub", destination: "mgr.jenkins.pub"
#vagrant.vm.provision :shell, :path => "buildup.sh"
#See issue vagrant forward port 22 unable to force
#https://stackoverflow.com/questions/30669183/forwarding-the-ssh-port-fails-when-running-two-vagrant-instances-from-the-same-h
#vagrant.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: "true"
vagrant.vm.network "forwarded_port", guest: 22, host: VAGRANT_SSH_PORT_03, id: 'ssh', auto_correct: "true"
vagrant.vm.network "forwarded_port", guest: 33224, host: 33224, auto_correct: true
# Do not use a shared folder. We will fetch sources in other ways.
# This allows us (eventually) to export the VM and move it around.
vagrant.vm.synced_folder ".", "/vagrant", disabled: true
end
config.vm.define :slave04 do |vagrant|
#https://atlas.hashicorp.com/ubuntu/boxes/trusty64
#vagrant.vm.box = "ubuntu/trusty64"
#https://atlas.hashicorp.com/ubuntu/boxes/xenial64
vagrant.vm.box = "ubuntu/xenial64"
vagrant.vm.boot_timeout = 600
vagrant.vm.hostname = HOSTNAME_04
vagrant.vm.network :private_network, ip: VAGRANT_NETWORK_IP_04
vagrant.vm.provider :virtualbox do |vb|
vb.name = HOSTNAME_04
#vb.customize ["modifyvm", :id, "--memory", "8192"]
vb.memory = 8192
vb.cpus = 4
end
#vagrant.vm.provision "file", source: "../keys/id_rsa", destination: "id_rsa"
#vagrant.vm.provision "file", source: "../keys/id_rsa.pub", destination: "id_rsa.pub"
#vagrant.vm.provision "file", source: "../keys/mgr.jenkins.pub", destination: "mgr.jenkins.pub"
#vagrant.vm.provision :shell, :path => "buildup.sh"
#See issue vagrant forward port 22 unable to force
#https://stackoverflow.com/questions/30669183/forwarding-the-ssh-port-fails-when-running-two-vagrant-instances-from-the-same-h
#vagrant.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: "true"
vagrant.vm.network "forwarded_port", guest: 22, host: VAGRANT_SSH_PORT_04, id: 'ssh', auto_correct: "true"
vagrant.vm.network "forwarded_port", guest: 33224, host: 33224, auto_correct: true
# Do not use a shared folder. We will fetch sources in other ways.
# This allows us (eventually) to export the VM and move it around.
vagrant.vm.synced_folder ".", "/vagrant", disabled: true
end
end
#Connect doing
#from outside host
#ssh -p 2251 vagrant@test
#ssh -p 2252 vagrant@test
#ssh -p 2253 vagrant@test
#ssh -p 2254 vagrant@test
#from inside host
#ssh -p 22 [email protected]
#ssh -p 22 [email protected]
#ssh -p 22 [email protected]
#ssh -p 22 [email protected]