-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
106 lines (96 loc) · 4 KB
/
Vagrantfile
File metadata and controls
106 lines (96 loc) · 4 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- mode: ruby -*-
# vi: set ft=ruby :
def Kernel.is_windows?
# Detect if we are running on Windows
processor, platform, *rest = RUBY_PLATFORM.split("-")
platform == 'mingw32'
end
conf = {
'http_proxy_host' => nil,
'http_proxy_port' => nil,
'https_proxy_host' => nil,
'https_proxy_port' => nil,
'socks_proxy_host' => nil,
'socks_proxy_port' => nil,
'ftp_proxy_host' => nil,
'ftp_proxy_port' => nil,
'no_proxy_domains' => nil,
'host_ip' => "10.10.10.5",
'ssh_dir' => '~/.ssh/',
'memory' => 4096,
'http_port_map' => 8888,
'ssh_port_map' => 2022,
'install_devstack' => true,
'devstack_branch' => 'master',
'stackuser' => 'vagrant',
'devstack_setup' => 'simple',
}
vd_conf = ENV.fetch('VD_CONF', 'etc/common.yaml')
if File.exist?(vd_conf)
require 'yaml'
user_conf = YAML.load_file(vd_conf)
conf.update(user_conf)
end
host_ip = conf['host_ip']
ssh_dir = conf['ssh_dir']
memory = conf['memory']
http_port_map = conf['http_port_map']
ssh_port_map = conf['ssh_port_map']
hostname = "devstack-" + conf['devstack_branch'].split('/').last
domain = "mylocalnet.com"
Vagrant.configure("2") do |config|
config.vm.hostname = hostname + '.' + domain
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "#{conf['http_proxy_host']}:#{conf['http_proxy_port']}"
config.proxy.https = "#{conf['https_proxy_host']}:#{conf['https_proxy_port']}"
config.proxy.no_proxy = conf['no_proxy_domains']
config.apt_proxy.http = "#{conf['http_proxy_host']}:#{conf['http_proxy_port']}"
end
config.vm.provider :vmware_fusion do |v, override|
override.vm.box = "precise64_vmware"
override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
v.vmx["memsize"] = memory
v.vmx["numvcpus"] = "4"
end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", memory ]
vb.customize ["modifyvm", :id, "--cpus", 4 ]
# If you don’t have a modern computer with CPU supporting hardware virtualization
# Uncomment next line (Be aware it will run much slower)
# vb.customize ["modifyvm", :id, “–hwvirtex”, “off”]
end
config.vm.network :private_network, ip: host_ip
#config.vm.boot_mode='gui'
if !Kernel.is_windows?
config.vm.synced_folder ssh_dir, "/home/vagrant/.host_ssh"
end
config.vm.network :forwarded_port, guest: 80, host: http_port_map
config.vm.network :forwarded_port, guest: 22, host: ssh_port_map
#config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
#puppet.manifest_file = "updatekernel.pp"
puppet.manifest_file = "vagrant.pp"
puppet.options = ["--verbose", "--node_name_value", config.vm.hostname]
puppet.options = puppet.options + ["--http_proxy_host", conf['http_proxy_host'], "--http_proxy_port", conf['http_proxy_port']] if !conf['http_proxy_host'].nil? && !conf['http_proxy_port'].nil? && !conf['http_proxy_host'].to_s.empty? && !conf['http_proxy_port'].to_s.empty?
puppet.facter = {
"http_proxy_host" => conf['http_proxy_host'],
"http_proxy_port" => conf['http_proxy_port'],
"https_proxy_host" => conf['https_proxy_host'],
"https_proxy_port" => conf['https_proxy_port'],
"socks_proxy_host" => conf['socks_proxy_host'],
"socks_proxy_port" => conf['socks_proxy_port'],
"ftp_proxy_host" => conf['ftp_proxy_host'],
"ftp_proxy_port" => conf['ftp_proxy_port'],
"no_proxy_domains" => conf['no_proxy_domains'],
"vm_type" => "vagrant",
"install_devstack" => conf['install_devstack'],
"devstack_branch" => conf['devstack_branch'],
"stackuser" => conf['stackuser'],
"devstack_setup" => conf['devstack_setup'],
}
end
end