forked from evrardjp/ansible-keepalived
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
76 lines (70 loc) · 2.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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Ansible provisioner for multimachine
ANSIBLE_RAW_SSH_ARGS = []
boxes = [
{
:name => "keepalived1",
:eth1 => "192.168.33.11",
:image => "ubuntu/trusty64",
},
{
:name => "keepalived2",
:eth1 => "192.168.33.12",
:image => "ubuntu/xenial64",
},
{
:name => "keepalived3",
:eth1 => "192.168.33.13",
:image => "ubuntu/xenial64",
},
{
:name => "keepalived4",
:eth1 => "192.168.33.14",
:image => "centos/7",
},
{
:name => "keepalived5",
:eth1 => "192.168.33.15",
:image => "debian/stretch64",
}
]
# Gather all the keys for the ssh connections
boxes.each do |boxopts|
ANSIBLE_RAW_SSH_ARGS << "-o IdentityFile=.vagrant/machines/#{boxopts[:name]}/virtualbox/private_key"
end
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", 256]
v.customize ["modifyvm", :id, "--cpus", 1]
end
# Optional vagrant cache
#if Vagrant.has_plugin?("vagrant-cachier")
# # http://fgrehm.viewdocs.io/vagrant-cachier/usage/
# config.cache.scope = :box
# #config.cache.synced_folder_opts = {
# # type: :nfs,
# # mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
# #}
#end
boxes.each do |boxopts|
config.vm.define boxopts[:name] do |config|
config.vm.box = boxopts[:image]
config.vm.hostname = boxopts[:name]
config.vm.network :private_network, ip: boxopts[:eth1]
# Vagrant works serially and provision machines
# serially. Each of them is unaware of the others.
# Therefore, we should start provisioning only on last machine
if boxopts[:name] == "keepalived5"
config.vm.provision :ansible do |ansible|
ansible.playbook = "tests/deploy.yml"
ansible.extra_vars = "tests/keepalived_haproxy_combined_example.yml"
ansible.limit = 'all'
#ansible.inventory_path = "tests/inventory"
ansible.verbose = "-vv"
ansible.raw_ssh_args = ANSIBLE_RAW_SSH_ARGS
end
end
end
end
end