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
77
|
# File 'lib/vagrant-dotvm/configinjecter.rb', line 5
def self.inject(config, vc)
vc.ssh.forward_x11 = true
config[:machines].each do |machine_cfg|
vc.vm.define machine_cfg[:nick], primary: machine_cfg[:primary] do |machine|
machine.vm.box = machine_cfg[:box]
machine.vm.hostname = machine_cfg[:name]
machine.vm.provider "virtualbox" do |vb|
vb.customize ['modifyvm', :id, '--memory', machine_cfg['memory'] ||= 1024]
vb.customize ['modifyvm', :id, '--cpus', machine_cfg['cpus'] ||= 1]
vb.customize ['modifyvm', :id, '--cpuexecutioncap', machine_cfg['cpucap'] ||= 100]
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natnet1', machine_cfg['natnet'] ||= '192.168.88.0/24']
end
machine_cfg[:networks].each do |net|
if net[:net] == 'private_network'
machine.vm.network net[:net],
type: net[:type] ||= 'static',
ip: net[:ip],
netmask: net[:mask],
virtualbox__intnet: net[:interface]
end
end
machine_cfg[:provision].each do |provision|
machine.vm.provision provision[:type] do |p|
if provision[:type] == 'shell'
p.path = provision[:path]
p.args = provision[:args]
p.privileged = provision[:privileged] ||= true
elsif provision[:type] == 'file'
p.source = provision[:source]
p.destination = provision[:destination]
elsif provision[:type] == 'puppet'
p.module_path = provision[:module_path]
p.manifest_file = provision[:manifest_file]
p.manifests_path = provision[:manifests_path]
end
end
end
machine_cfg[:folders].each do |folder|
machine.vm.synced_folder folder[:host], folder[:guest], disabled: folder[:disabled]
end
machine_cfg[:authorized_keys].each do |key|
if key[:type] == 'file'
pubkey = File.readlines(File.expand_path(key[:path])).first.strip
elsif key[:type] == 'static'
pubkey = key[:key]
end
machine.vm.provision 'shell' do |s|
s.path = File.dirname(__FILE__) + "/../../utils/authorize_key.sh"
s.args = [pubkey]
s.privileged = false
end
end
if Vagrant.has_plugin?('vagrant-group')
vc.group.groups = {} unless vc.group.groups.kind_of?(Hash)
machine_cfg[:groups].each do |group|
vc.group.groups[group] = [] unless vc.group.groups.has_key?(group)
vc.group.groups[group] << machine_cfg[:nick]
end
end
end
end
end
|