-
Notifications
You must be signed in to change notification settings - Fork 4
/
Vagrantfile
47 lines (41 loc) · 1.8 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
require 'yaml'
def escape(s)
"\"" + s.gsub("\\", "\\\\").gsub("\"", "\\\"") + "\""
end
directory = YAML.load_file("directory.conf.yml")
username = "root"
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder 'common', '/vagrant_common', type: "rsync"
directory['machines'].each do |machine|
config.vm.define machine['name'] do |config|
config.vm.hostname = machine['name']
config.vm.box = machine['box']
config.vm.provider :libvirt do |libvirt|
libvirt.host = machine['hypervisor']['name']
libvirt.connect_via_ssh = true
libvirt.username = machine['hypervisor']['username']
libvirt.memory = machine['memory']
libvirt.cpus = machine['vcpus']
libvirt.cpu_mode = 'host-passthrough'
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "devstack.yml"
ansible.raw_arguments = "-vvv"
ansible.host_vars = {machine['name'] => {"ansible_ssh_common_args": escape("-o ProxyCommand=\"ssh '#{machine['hypervisor']['name']}' -l '#{machine['hypervisor']['username']}' -i '/#{ENV['HOME']}/.ssh/id_rsa' nc %h %p\"")}}
ansible.extra_vars = {
local_conf_file: machine['local_conf_file'],
projects: machine['projects'],
devstack_version: machine['devstack_version']
}
end
end
end
end