-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
executable file
·194 lines (170 loc) · 6.19 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# vim: ai ts=3 sts=2 et sw=2 ft=ruby
# vim: autoindent tabstop=2 shiftwidth=2 expandtab softtabstop=2 filetype=ruby
#
chef0_ip = '172.16.1.2'
chef0_port = '4000'
proxy_http = 'http://172.16.1.1:6060/'
proxy_https = 'http://172.16.1.1:6060/'
noproxy = 'localhost,127.0.0.1,.local'
cookbook_testers = {
#:centos64 => {
#:vmbox_url => "https://github.com/2creatives/vagrant-centos/releases/" +
#"download/v0.1.0/centos64-x86_64-20131030.box",
#:hostname => "centos64-cookbook-test",
#:ipaddress => "172.16.1.10",
#:disks => {
#:disk1 => {
#:size => "50",
#:filesystem => "ext4",
#:mountname => "mnt1",
#:mountpoint => "/mnt/mnt1",
#:volgroupname => "vg01"
#}
#},
#:run_list => [ "recipe[ntp]", "recipe[apache]" ]
#},
:precise => {
:vmbox_name => 'precise64',
:vmbox_url => 'http://files.vagrantup.com/precise64.box',
:hostname => "precise-cookbook-test",
:ipaddress => "172.16.1.11",
:run_list => "recipe[ntp]",
:on_boot => [ "apt-get update",
"echo -e 'vagrant\nvagrant' | passwd root "
],
:os_type => "linux",
:ram => 1024,
:vrde_port => 8011,
:forward_ports => [ 3389, 8112,
22, 8212,
80, 8312 ],
:proxy_http => proxy_http,
:proxy_https => proxy_https,
:noproxy => noproxy
},
:WIN2K8R2 => {
:vmbox_name => 'WIN2K8R2',
:vmbox_url => 'http://109.169.95.220/WIN2K8R2.box',
:hostname => "win2k8-cookbook-test",
:ipaddress => "172.16.1.12",
:run_list => "recipe[windows]",
:on_boot => [],
:os_type => "windows",
:ram => 2048,
:vrde_port => 8012,
:forward_ports => [ 3389, 8112,
22, 8212,
80, 8312,
5985, 5985 ]
}
}
Vagrant.require_plugin "vagrant-chefzero"
Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.require_plugin "vagrant-omnibus"
Vagrant.configure("2") do |global_config|
global_config.vm.define :chefzero do |config|
config.vm.network :private_network, ip: chef0_ip
config.vm.hostname = "chefzero"
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
config.berkshelf.enabled = false
config.cache.auto_detect = true
config.hostmanager.enabled = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.manage_host = true
config.vbguest.auto_update = true
config.vbguest.auto_reboot = true
config.vm.boot_timeout = 300
config.env_proxy.http = proxy_http
config.env_proxy.https = proxy_https
config.env_proxy.no_proxy = noproxy
config.vm.provision :chefzero do |vm|
vm.ip = chef0_ip
vm.port = chef0_port
vm.setup do |p|
p.import_berkshelf_cookbooks
end
end
end
cookbook_testers.each_pair do |name, options|
global_config.vm.define name do |config|
vm_name = "#{name}-cookbook-test"
ipaddress = options[:ipaddress]
#configuration for vagrant plugins:
# (cachier, berkshelf, hostmanager, omnibus, vbox, chef_zero)
config.berkshelf.enabled = true
config.cache.auto_detect = true
config.hostmanager.enabled = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.manage_host = true
config.vbguest.auto_update = true
config.vbguest.auto_reboot = true
config.vm.boot_timeout = 300
config.vm.box = options[:vmbox_name]
config.vm.box_url = options[:vmbox_url]
config.vm.hostname = name.to_s
config.vm.network "private_network", ip: ipaddress
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider "virtualbox" do |v|
v.gui = true
v.customize ["modifyvm", :id, "--memory", options[:ram] ]
v.customize ["modifyvm", :id, "--vrde", "on" ]
v.customize ["modifyvm", :id, "--vrdeport", options[:vrde_port] ]
end
case options[:os_type]
when "windows"
config.windows.halt_timeout = 25
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
options[:forward_ports].each_slice(2) do |p_guest, p_host|
config.vm.network :forwarded_port, guest: p_guest, host: p_host
end
when "linux"
unless options[:proxy_http].nil?
config.env_proxy.http = options[:proxy_http]
config.env_proxy.https = options[:proxy_https]
config.env_proxy.no_proxy = options[:noproxy]
end
config.omnibus.chef_version = :latest
unless options[:disks].nil?
options[:disks].each_pair do |disk_name, disk_options|
config.persistent_storage.enabled = true
config.persistent_storage.location = "./#{name.to_s}-#{disk_name}"
config.persistent_storage.size = disk_options[:size]
config.persistent_storage.mountname = disk_options[:mountname]
config.persistent_storage.filesystem = disk_options[:filesystem]
config.persistent_storage.mountpoint = disk_options[:mountpoint]
config.persistent_storage.volgroupname = disk_options[:volgroupname]
end
end
unless options[:on_boot].nil?
options[:on_boot].each do |action|
config.vm.provision "shell" do |s|
s.inline = action
end
end
end
end
config.vm.provision :chef_client do |chef|
chef.node_name = vm_name
chef.provisioning_path = "/etc/chef"
chef.chef_server_url = "http://#{chef0_ip}:#{chef0_port}"
chef.validation_key_path = Vagrant::ChefzeroPlugin.pemfile
chef.client_key_path = Vagrant::ChefzeroPlugin.pemfile
chef.log_level = :info
run_list = []
run_list << ENV['CHEF_RUN_LIST'].split(",") if ENV.has_key?('CHEF_RUN_LIST')
chef.run_list = [options[:run_list].split(","), run_list].flatten
chef.json = {
'vagrant-httpproxy' => {
'proxy-host' => "172.16.1.1",
'proxy-port' => "8123"
}
}
end
end
end
end