-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
55 lines (41 loc) · 1.58 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANT_ROOT = File.dirname(File.expand_path(__FILE__))
# Require YAML module
require 'yaml'
# Read YAML file with box details
serverfile = File.join(VAGRANT_ROOT,'servers.yaml')
boxes = YAML.load_file(serverfile)
Vagrant.configure(2) do |config|
config.vm.network "private_network", type: "dhcp"
config.vm.box = "centos7base"
config.ssh.forward_agent = true
config.hostmanager.enabled = true
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
if vm.id
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
end
end
config.puppet_install.puppet_version = "3.8.2"
config.vm.provision :shell, inline: 'gem install deep_merge'
config.vm.provision :puppet, run: "always" do |puppet|
puppet.hiera_config_path = "puppet/hiera.yaml"
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.manifest_file = "site.pp"
end
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider :virtualbox do |vb|
if opts[:datadisk]
file_to_disk = File.join(VAGRANT_ROOT,"#{config.vm.hostname}_datadisk.vdi")
unless File.exist?(file_to_disk)
vb.customize ['createhd', '--filename', file_to_disk, '--size', opts[:datadisk].to_i * 1024]
end
vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end
end
end
end
end