-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
239 lines (230 loc) · 8.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Copyright 2013 Inktank LLC, <[email protected]>
Vagrant.configure('2') do |config|
use_aws = false
#TODO: check that the number of OSDs <= 154 until refactoring network bits
if Vagrant.has_plugin?('AWS')
puts 'INFO: Vagrant-aws plugin detected.'
if !ENV['ACCESS_KEY_ID'].nil? && !ENV['SECRET_ACCESS_KEY'].nil?
puts "INFO: AWS credentials detected, will launch cluster on EC2"
use_aws = true
def config_aws(instance,name,instance_type,ami,private_ip_address)
instance.vm.box = 'aws-box-url'
instance.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['ACCESS_KEY_ID']
aws.secret_access_key = ENV['SECRET_ACCESS_KEY']
aws.keypair_name = "vagrant"
#aws.ami = ami
aws.instance_type = instance_type
aws.region = "us-east-1"
#aws.availability_zone = ""
aws.private_ip_address = private_ip_address
#aws.subnet_id = "subnet-asdf"
#aws.elastic_ip = true
#aws.tags = {"name": "#{name}"}
end
end
else
# Local caching only makes sense when using VirtualBox
puts 'WARN: Vagrant-aws plugin not detected. Cannot launch cluster on EC2.'
if Vagrant.has_plugin?('vagrant-cachier')
puts 'INFO: Vagrant-cachier plugin detected. Optimizing caches.'
config.cache.auto_detect = true
config.cache.enable :chef
config.cache.enable :apt
else
puts 'WARN: Vagrant-cachier plugin not detected. Continuing unoptimized.'
end
end
end
# Chef Server Definition
#
config.vm.define :chefserver do |chefserver|
chefserver.vm.hostname = 'chefserver'
chefserver.ssh.username = 'vagrant'
if use_aws == true
# TODO: Bake chefserver AMI
config_aws(chefserver,'chefserver','m1.large','ami-chefserver','192.168.3.100')
else
chefserver.vm.box = 'chefserver'
chefserver.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/chefserver-new.box'
chefserver.vm.network 'private_network', ip: '192.168.3.100'
config.vm.provider :virtualbox do |vb|
vb.name = 'chefserver'
vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '2']
end
end
chefserver.vm.provision 'shell', path: 'scripts/chef-server.sh'
end
# Ceph Monitor Definition
#
# TODO: Allow multiple monitors to be launched
config.vm.define :cephmon do |cephmon|
cephmon.vm.hostname = 'cephmon'
cephmon.ssh.username = 'vagrant'
if use_aws == true
config_aws(cephmon,'cephmon','m1.large','ami-precise','192.168.3.101')
else
cephmon.vm.box = 'precise64chef'
cephmon.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/precise64chef.box'
cephmon.vm.network "private_network", ip: '192.168.3.101'
config.vm.provider :virtualbox do |vb|
vb.name = 'cephmon'
vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '2']
end
end
cephmon.vm.provision :chef_client do |chef|
chef.chef_server_url = 'https://192.168.3.100'
chef_validation_client_name = 'chef-validator'
chef.validation_key_path = 'chef/chef-validator.pem'
chef.environment = 'cluster'
chef.add_recipe 'ceph::repo'
chef.add_recipe 'ceph::conf'
chef.add_recipe 'ceph::mon'
end
end
# Ceph Metadata Server Definition
#
# Only create a MDS VM if shell environmental variable is set
# TODO: Allow multiple metadata servers to be launched
if ENV['VAGRANT_CEPH_MDS'] == 'y'
puts "INFO: VAGRANT_CEPH_MDS=y creating MDS"
config.vm.define :cephmds do |cephmds|
cephmds.vm.hostname = 'cephmds'
cephmds.ssh.username = 'vagrant'
if use_aws == true
config_aws(cephmds,'cephmds','m1.large','ami-precise','192.168.3.110')
else
cephmds.vm.box = 'precise64'
cephmds.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/precise64chef.box'
cephmds.vm.network 'private_network', ip: '192.168.3.103'
config.vm.provider :virtualbox do |vb|
vb.name = 'cephmds'
vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '2']
end
end
cephmds.vm.provision :chef_client do |chef|
chef.chef_server_url = 'https://192.168.3.100'
chef_validation_client_name = 'chef-validator'
chef.validation_key_path = 'chef/chef-validator.pem'
chef.environment = 'cluster'
chef.add_role 'ceph::mds'
end
end
else
puts "INFO: VAGRANT_CEPH_MDS unset, skipping MDS creation"
end
# Ceph Storage Server Definitions
#
num_osds = ENV['VAGRANT_CEPH_NUM_OSDS'].to_i
puts "INFO: VAGRANT_CEPH_NUM_OSDS set to #{num_osds}, creating #{num_osds} cephstores"
num_osds.times do |i|
cephstore_name = "cephstore100#{i}"
config.vm.define "cephstore100#{i}" do |cephstore|
octect = 199 + num_osds
ip = '192.168.3.' << octect.to_s
cephstore_name = "cephstore100#{i}"
cephstore.vm.hostname = "#{cephstore_name}"
cephstore.ssh.username = 'vagrant'
if use_aws == true
config_aws(cephstore,cephstore_name,'m1.small','ami-bd6d40d4',ip)
else
cephstore.vm.box = 'precise64'
cephstore.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/precise64chef.box'
cephstore.vm.network 'private_network', ip: ip
file_to_disk = "./tmp/#{cephstore_name}.osd_data.vdi"
config.vm.provider :virtualbox do |vb|
vb.name = "#{cephstore_name}"
vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '1']
vb.customize ['createhd', '--filename', file_to_disk, '--size', 10480]
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end
end
cephstore.vm.provision :chef_client do |chef|
chef.chef_server_url = 'https://192.168.3.100'
chef_validation_client_name = 'chef-validator'
chef.validation_key_path = 'chef/chef-validator.pem'
chef.environment = 'cluster'
chef.add_recipe 'ceph::repo'
chef.add_recipe 'ceph::conf'
chef.add_recipe 'ceph::osd'
chef.json = {
"ceph" => {
"osd_devices" => [
{
"device" => "/dev/sdb",
"dmcrypt" => false
}
]
}
}
end
end
end
# Ceph Object Storage Gateway Definition
#
# TODO: Allow multiple RGW VMs to be launched
if ENV['VAGRANT_CEPH_RGW'] == 'y'
puts "INFO: VAGRANT_CEPH_RGW=y creating RGW"
config.vm.define :cephrgw do |cephrgw|
cephrgw.vm.hostname = 'cephrgw'
cephrgw.ssh.username = 'vagrant'
if use_aws == true
config_aws(cephrgw,'cephrgw','m1.xlarge','ami-precise','192.168.3.120')
else
cephrgw.vm.box = 'precise64'
cephrgw.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/precise64chef.box'
cephrgw.vm.network 'private_network', ip: '192.168.3.120'
config.vm.provider :virtualbox do |vb|
vb.name = 'cephrgw'
vb.customize ['modifyvm', :id, '--memory', '1024']
end
end
cephrgw.vm.provision :chef_client do |chef|
chef.chef_server_url = 'https://192.168.3.100'
chef_validation_client_name = 'chef-validator'
chef.validation_key_path = 'chef/chef-validator.pem'
chef.environment = 'cluster'
chef.add_recipe 'ceph::repo'
chef.add_recipe 'ceph::conf'
chef.add_role 'ceph::radosgw'
end
end
else
puts "INFO: VAGRANT_CEPH_RGW unset, skipping RGW creation"
end
# Ceph Kernel RADOS Block Device Client Definition
#
# TODO: Allow multiple KRBD clients VMs to be launched
if ENV['VAGRANT_CEPH_KRBD'] == 'y'
puts "INFO: VAGRANT_CEPH_KRBD=y creating KRBD"
config.vm.define :krbd do |krbd|
krbd.vm.hostname = 'krbd'
krbd.ssh.username = 'vagrant'
if use_aws == true
config_aws(krbd,'krbd','m1.small','ami-precise','192.168.3.130')
else
krbd.vm.box = "precise64"
krbd.vm.box_url = 'https://objects.dreamhost.com/vagrant-ceph/precise64chef.box'
krbd.vm.network 'private_network', ip: '192.168.3.130'
config.vm.provider :virtualbox do |vb|
vb.name = 'krbd'
vb.customize ['modifyvm', :id, '--memory', '2048', '--cpus', '2']
end
end
krbd.vm.provision :chef_client do |chef|
chef.chef_server_url = 'https://192.168.3.100'
chef_validation_client_name = 'chef-validator'
chef.validation_key_path = 'chef/chef-validator.pem'
chef.environment = 'cluster'
chef.add_recipe 'ceph::repo'
chef.add_recipe 'ceph::conf'
chef.add_role 'ceph::rbd'
end
end
else
puts "INFO: VAGRANT_CEPH_KRBD unset, skipping KRBD creation"
end
# TODO: Add some cephfs client love
end