-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVagrantfile
90 lines (88 loc) · 3.55 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
VAGRANTFILE_API_VERSION = "2"
nodes = ['ceph1', 'ceph2', 'ceph3', 'ceph4']
network = "192.168.5"
ceph1ip = "#{network}.2"
ceph2ip = "#{network}.3"
ceph3ip = "#{network}.4"
ceph4ip = "#{network}.5"
osd_nodes = []
subnet=1
domain='ceph.local'
nodes.each { |node_name|
(1..1).each {|n|
subnet += 1
osd_nodes << {:hostname => "#{node_name}"}
}
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
osd_nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.host_name = "#{node[:hostname]}.#{domain}"
node_config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
node_config.vm.provision "shell" do |s|
s.inline = "echo '192.168.5.2 ceph1 ceph1.local ceph1.ceph.local' | sudo tee -a /etc/hosts"
end
if node[:hostname] != "ceph1"
(0..1).each do |d|
node_config.vm.provider "virtualbox" do |vb|
vb.customize [ "createmedium", "disk", "--format", "VDI", "--filename", "disk-#{node[:hostname]}-#{d}", "--size", "2048"]
vb.customize [ "storageattach", :id, "--storagectl", "SATAController", "--port", 3+d, "--device", 0, "--type", "hdd", "--medium", "disk-#{node[:hostname]}-#{d}.vdi" ]
end
end
end
if node[:hostname] == "ceph1"
node_config.vm.network "private_network", ip: "#{ceph1ip}"
end
if node[:hostname] == "ceph2"
node_config.vm.network "private_network", ip: "#{ceph2ip}"
node_config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
end
if node[:hostname] == "ceph3"
node_config.vm.network "private_network", ip: "#{ceph3ip}"
end
if node[:hostname] == "ceph4"
node_config.vm.network "private_network", ip: "#{ceph4ip}"
node_config.vm.provision "vai" do |ansible|
ansible.inventory_dir = 'ansible/inventory'
ansible.groups = {
'osds' => ["ceph2", "ceph3", "ceph4"],
'mons' => ["ceph2", "ceph3", "ceph4"],
'mdss' => ["ceph1"],
'rdgws' => ["ceph1"],
'flocker_agents' => ["ceph2", "ceph3", "ceph4"],
'flocker_control_service' => ["ceph1"],
'flocker_docker_plugin' => ["ceph2", "ceph3", "ceph4"],
'flocker_ceph' => ["ceph2", "ceph3", "ceph4"],
'nodes:children' => ["flocker_agents", "flocker_control_service"]
}
end
node_config.vm.provision "ansible" do |ansible|
ansible.playbook = 'site.yml'
ansible.limit = "all"
ansible.groups = {
'osds' => ["ceph2", "ceph3", "ceph4"],
'mons' => ["ceph2", "ceph3", "ceph4"],
'mdss' => ["ceph1"],
'rdgws' => ["ceph1"],
'flocker_agents' => ["ceph2", "ceph3", "ceph4"],
'flocker_control_service' => ["ceph1"],
'flocker_docker_plugin' => ["ceph2", "ceph3", "ceph4"],
'flocker_ceph' => ["ceph2", "ceph3", "ceph4"],
'nodes:children' => ["flocker_agents", "flocker_control_service", "flocker_docker_plugin", "flocker_ceph"]
}
ansible.extra_vars = {
fsid: "4a158d27-f750-41d5-9e7f-26ce4c9d2d45",
monitor_secret: "AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw==",
flocker_agent_yml_path: "../agent.yml"
}
end
end
end
end
end