-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
66 lines (60 loc) · 1.84 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 :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
VAGRANT_CONFIG = "./config.yaml"
Default_Box = [{
'hostname' => 'ubuntu101',
'box_name' => 'ubuntu',
'box_url' => 'https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box',
'network' => [
{
'name' => 'private_network',
'ip' => '10.99.250.10'
}
],
'spec' => {
'cpus' => 1,
'memory' => 2048,
'biosbootmenu' => 'disabled'
}
}]
def vagrant_boxes &block
@config = ( File.exist?( VAGRANT_CONFIG ) ) ? load_box_config : Default_Box
@config['boxes'].each { |x| yield x }
end
def load_box_config
YAML.load(File.read(VAGRANT_CONFIG)) || []
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box_check_update = false
if File.exists?('./puppet')
config.vm.synced_folder 'puppet/', '/etc/puppet', disabled: false
end
vagrant_boxes do |settings|
config.vm.define settings['hostname'] do |x|
if settings['bootstrap']
case settings['bootstrap']['type']
when 'inline'
when 'script'
config.vm.provision :shell, :path => settings['bootstrap']['script']
end
end
x.vm.box = settings['box_name']
x.vm.box_url = settings['box_url']
x.vm.host_name = settings['hostname']
( settings['networks'] || [] ).each do |n|
x.vm.network n['name'], type: :dhcp if n['type'] == 'dhcp'
x.vm.network n['name'], ip: n['ip'] if n['ip']
end
x.vm.provider :virtualbox do |v|
v.gui = settings['gui'] || false
v.name = settings['hostname']
(settings['spec'] || {}).each_pair do |key,value|
v.customize [ "modifyvm", :id, "--#{key}", value ]
end
end
end
end
end