-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathVagrantfile_Multi
55 lines (49 loc) · 2.1 KB
/
Vagrantfile_Multi
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
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
servers = { :"app-host-1" => '192.168.99.11',
:"app-host-2" => '192.168.99.22',
:"web-db-host" => '192.168.99.44',
}
last_host_name = "cache-host"
last_host_ip = "192.168.99.99"
#
# The provisioner is run for every host, right after the host has
# booted up. This is unfortunate, since we'd rather wait with the
# Ansible run until all hosts are up. Therefore, we have all the
# hosts, except the last one, without provisioner.
#
servers.each do |server_name, server_ip|
config.vm.define server_name do |server_conf|
server_conf.vm.box = "saucy64"
server_conf.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
server_conf.vm.host_name = server_name.to_s
server_conf.vm.network "private_network", ip: server_ip
end
end
#
# By listing the last host separately, we force it to be brought up
# last. Thus, the provisioner is run only for this last host,
# meaning: We can guarantee that all hosts are up and running when
# the provisioner kicks in.
#
config.vm.define last_host_name do |server_conf|
server_conf.vm.box = "saucy64"
server_conf.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
server_conf.vm.host_name = last_host_name
server_conf.vm.network "private_network", ip: last_host_ip
server_conf.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
#ansible.verbose = "vvvv"
ansible.inventory_path = "vagrant_hosts_multi"
ansible.extra_vars = "vars/vagrant_extra_vars.yml"
ansible.host_key_checking = false
end
end
#
# Adding a little more memory
#
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end