forked from Icinga/ansible-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
59 lines (50 loc) · 1.79 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
boxes = [
{ :name => "icinga2-web2-mysql", :eth1 => "172.16.1.2" },
{ :name => "icinga2-web2-postgres", :eth1 => "172.16.1.3" }
]
Vagrant.configure("2") do |config|
config.vm.box = "jhcook/centos7"
config.vm.box_url = "https://atlas.hashicorp.com/jhcook/boxes/centos7"
config.vm.synced_folder ".", "/vagrant", disabled: true
boxes.each do |opts|
config.vm.define opts[:name] do |node|
# VM Config
node.vm.hostname = opts[:name]
node.vm.network "private_network", ip: opts[:eth1]
config.vm.provider "virtualbox" do |v|
if opts[:memory]
v.memory = opts[:memory]
else
# Default memory
v.memory = 1024
end
if opts[:cpus]
v.cpus = opts[:cpus]
else
# Default cpus
v.cpus = 1
end
end
# Ansible Config
node.vm.provision "ansible" do |ansible|
ansible.limit = opts[:name]
ansible.inventory_path = "hosts"
# Set playbook
if opts[:playbook]
ansible.playbook = "playbooks/" + opts[:playbook]
else
# Default playbook name
ansible.playbook = "playbooks/" + opts[:name] + "-setup.yml"
end
# Set verbose level
if opts[:verbose]
ansible.verbose = opts[:verbose]
end
# Set extra_vars
if opts[:extra_vars]
ansible.extra_vars = opts[:extra_vars]
end
end
end
end
end