-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
67 lines (53 loc) · 1.65 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
machines_file = ENV['MACHINES']
machines_file ||= './vagrant/one_machine'
require machines_file
# Assign machines to their Ansible groups
def generate_ansible_groups(machines)
require 'set'
ansible_groups = {}
all = Set.new
machines.each do |m|
m["ansible_groups"].each do |group|
if not ansible_groups.has_key?(group)
ansible_groups[group] = []
end
ansible_groups[group].push(m["hostname"])
all = all.add(group)
end
end
return ansible_groups
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "ansible" do |ansible|
ansible.groups = generate_ansible_groups(MACHINES)
ansible.playbook = "main.yml"
ansible.extra_vars = { mongodb_host: MONGO_HOST }
# Useful during testing
ansible.host_key_checking = false
# ansible.verbose = "vvvv"
# ansible.inventory_path = "path" # In this case we directly generate it
# ansible.limit = "local"
# ansible.raw_arguments = "--ask-vault-pass"
end
# Disabling the default /vagrant share.
# http://docs.vagrantup.com/v2/synced-folders/
# (Reason to disable it: In MacOS GuestAdditions trend to fail screwing the "up" or "reload".
config.vm.synced_folder ".", "/vagrant", disabled: true
MACHINES.each do |m|
config.vm.define m["hostname"] do |node|
node.vm.box = m["box"]
node.vm.hostname = m["hostname"]
node.vm.network :private_network, ip: m["ip"]
m["ports"].each do |port|
node.vm.network :forwarded_port, guest: port[0], host: port[1]
end
node.vm.provider :virtualbox do |vb|
vb.cpus = m["cpus"]
vb.memory = m["memory"]
end
end
end
end