forked from mglaman/aegir-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
75 lines (59 loc) · 2.43 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
require 'yaml'
dir = File.dirname(File.expand_path(__FILE__))
configValues = YAML.load_file("#{dir}/config.yml")
data = configValues['vagrantfile']
Vagrant.configure("2") do |config|
config.vm.box = "#{data['vm']['box']}"
config.vm.box_url = "#{data['vm']['box_url']}"
if data['vm']['hostname'].to_s.strip.length != 0
config.vm.hostname = "#{data['vm']['hostname']}"
end
if data['vm']['network']['private_network'].to_s != ''
config.vm.network 'private_network', ip: "#{data['vm']['network']['private_network']}"
end
data['vm']['network']['forwarded_port'].each do |i, port|
if port['guest'] != '' && port['host'] != ''
config.vm.network :forwarded_port, guest: port['guest'].to_i, host: port['host'].to_i
end
end
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
data['vm']['shared_dirs'].each do |i, folder|
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
mount_options: [
"dmode=775",
"fmode=664",
"uid=#{data['vm']['aegir_user']['uid']}",
"gid=#{data['vm']['aegir_user']['gid']}"
]
end
config.vm.usable_port_range = (10200..10500)
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
config.vm.provider "virtualbox" do |virtualbox|
virtualbox.customize ['modifyvm', :id, "--natdnshostresolver1", "on"]
virtualbox.customize ['modifyvm', :id, '--memory', "#{data['vm']['memory']}"]
virtualbox.customize ['modifyvm', :id, '--cpus', "#{data['vm']['cpus']}"]
if data['vm']['hostname'].to_s.strip.length != 0
virtualbox.customize ['modifyvm', :id, '--name', config.vm.hostname]
end
end
config.vm.provision :puppet do |puppet|
puppet.facter = {
'ssh_username' => "vagrant",
'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
'vm_target_key' => "vagrantfile-local",
'fqdn' => "#{data['vm']['hostname']}",
}
puppet.manifests_path = "#{dir}/.config/puppet/"
puppet.manifest_file = "site.pp"
puppet.module_path = [
File.expand_path("#{dir}/.config/puppet/modules"),
]
end
config.vm.provision :shell, :path => ".config/scripts/startup.sh"
end