This repository was archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathVagrantfile
75 lines (63 loc) · 2.84 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
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version '>= 1.6.0'
Vagrant.configure('2') do |config|
hosts = {
'dockertutorial-01' => {
'address' => '192.168.123.140',
'memory' => 1024,
'cpus' => 2
},
'dockertutorial-02' => {
'address' => '192.168.123.141',
'memory' => 512,
'cpus' => 1
},
'dockertutorial-03' => {
'address' => '192.168.123.142',
'memory' => 512,
'cpus' => 1
}
}
# Resolve stdin: is not a tty in ubuntu over vagrant
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
hosts.each do |host, params|
config.vm.define host, autostart: true do |host_config|
host_config.vm.box = 'bfraser/dockertutorial'
host_config.vm.hostname = "#{host}"
host_config.vm.network :private_network, ip: params['address']
host_config.vm.provider :libvirt do |libvirt, override|
# Remember to run with --provider=libvirt otherwise Vagrant will execute also the virtualbox section!
override.vm.synced_folder '.', '/vagrant', disabled: true
override.vm.synced_folder './ansible-local/', '/tmp/vagrantupansible', type: 'rsync'
override.vm.synced_folder './ansible_build_deploy/', '/vagrant/ansible_build_deploy/', type: 'rsync', create: true
libvirt.driver = 'kvm'
libvirt.storage_pool_name = 'default'
libvirt.management_network_name = 'vagrant'
libvirt.management_network_address = '192.168.123.0/24'
libvirt.memory = params['memory']
libvirt.cpus = params['cpus']
end
host_config.vm.provider :virtualbox do |virtualbox, override|
# Use virtualbox synced folders, should work in all operating systems
override.vm.synced_folder '.', '/vagrant', disabled: true
override.vm.synced_folder './ansible-local/', '/tmp/vagrantupansible'
override.vm.synced_folder './ansible_build_deploy/', '/vagrant/ansible_build_deploy/', create: true
virtualbox.memory = params['memory']
virtualbox.cpus = params['cpus']
end
host_config.vm.provider :vmware_fusion do |vmwarefusion, override|
override.vm.synced_folder '.', '/vagrant', disabled: true
override.vm.synced_folder './ansible-local/','/tmp/vagrantupansible', type: 'rsync'
override.vm.synced_folder './ansible_build_deploy/','/vagrant/ansible_build_deploy/', type: 'rsync', create: true
vmwarefusion.vmx['memsize'] = params['memory']
vmwarefusion.vmx['numvcpus'] = params['cpus']
end
host_config.vm.provision :shell, inline: "ansible-playbook /tmp/vagrantupansible/playbooks/#{host}.yml"
if (/dockertutorial-01/ =~ host) != nil
host_config.vm.provision :shell, inline: "ansible-playbook /vagrant/ansible_build_deploy/run_haproxy_via_consultemplate.yml"
end
end
end
end