forked from andkononykhin/cortx-prvsnr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile_VBox
179 lines (155 loc) · 5.99 KB
/
Vagrantfile_VBox
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
# vi: set ft=ruby :
# Vagrantfile configuration fefernece:
# https://www.vagrantup.com/docs/hyperv/configuration.html
# read vm configuration(s) from JSON file
salt_nodes = [
{
"name" => "srvnode-1",
"cpus" => 2,
"memory" => 4096,
"mgmt0" => "172.16.10.101",
"data0" => "172.19.10.101",
"minion_id" => "srvnode-1"
},
{
"name"=> "srvnode-2",
"cpus"=> 2,
"memory"=> 4096,
"mgmt0" => "172.16.10.102",
"data0" => "172.19.10.102",
"minion_id" => "srvnode-2"
},
{
"name"=> "s3client",
"cpus"=> 2,
"memory"=> 2048,
"mgmt0" => "172.16.10.103",
"data0" => "172.19.10.103",
"minion_id" => "s3client"
}
]
# Disk configuration details
disks_dir = File.join(Dir.pwd, ".vagrant", "vdisks")
disk_count = 2
disk_size = 2048 # in MB
Vagrant.configure("2") do |config|
salt_nodes.each do |node|
config.vm.define node['name'] do |node_config|
# Configure salt nodes
node_config.vm.box_url = "http://cortx-storage.colo.seagate.com/prvsnr/vendor/centos/vagrant.boxes/centos_7.7.1908.box"
node_config.vm.box_download_insecure = true
node_config.vm.box = "centos_7.7.1908_vbox"
node_config.vm.box_check_update = false
node_config.vm.boot_timeout = 600
node_config.vm.hostname = node['name']
node_config.vm.provider :virtualbox do |vb, override|
# Headless
vb.gui = false
# name
vb.name = node['name']
# Virtual h/w specs
vb.memory = node['memory']
vb.cpus = node['cpus']
# Use differencing disk instead of cloning entire VDI
vb.linked_clone = false
## Network configuration
override.vm.network :private_network, ip: node['mgmt0'], virtualbox__intnet: "mgmt0"
override.vm.network :private_network, ip: node['data0'], virtualbox__intnet: "data0"
# Disable USB
vb.customize ["modifyvm", :id, "--usb", "off"]
vb.customize ["modifyvm", :id, "--usbehci", "off"]
unless 's3client' == node['name']
# Check if machine already provisioned
if not File.exist?(File.join(Dir.pwd, "/.vagrant/machines/default/virtualbox/id"))
# VDisk configuration start
if not Dir.exist?(disks_dir)
Dir.mkdir(disks_dir)
end
# SAS Controller - 1
vb.customize [ 'storagectl',
:id,
'--name', "#{node['name']}_vdisk_vol_1",
'--add', 'sas',
'--controller', 'LSILogicSAS',
'--portcount', 2,
'--hostiocache', 'off',
'--bootable', 'off'
]
(1..disk_count).each do |disk_number|
disk_file = File.expand_path(disks_dir).to_s + "/#{node['name']}_disk_#{disk_number}.vdi"
# Note: Create a hard disk image: vboxmanage createmedium --filename $PWD/disk_<vm_name>_<disk_count>.vdi --size <disk_size> --format VDI
if not File.exist?(disk_file)
vb.customize ['createmedium',
'disk',
'--filename', disk_file,
'--size', disk_size * disk_number,
'--format', 'VDI',
'--variant', 'Standard'
]
end
# Attach hard disk
# see https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach
vb.customize [
'storageattach',
:id,
'--storagectl', "#{node['name']}_vdisk_vol_1",
'--port', disk_number - 1,
'--device', 0,
'--type', 'hdd',
'--medium', disk_file,
'--mtype', 'normal'
]
end # Disk creation loop
# VDisk configuration end
end # Provisioned machine check
end # End of Unless
end # Virtualbox provisioner
# Folder synchonization
node_config.vm.synced_folder ".", "/opt/seagate/cortx/provisioner",
type: "rsync",
rsync__args: ["--archive", "--delete", "-z", "--copy-links"],
rsync__auto: true,
rsync__exclude: [".git", ".gitignore", ".vagrant", "Vagrantfile"],
rsync__verbose: true
node_config.vm.provision "shell",
name: "Boootstrap VM",
run: "once",
path: './files/scripts/setup/bootstrap.sh',
privileged: true
node_config.vm.provision "shell",
name: "Vagrant_override",
#run: "once",
inline: <<-SHELL
sudo cp /opt/seagate/cortx/provisioner/files/etc/sysconfig/network-scripts/ifcfg-* /etc/sysconfig/network-scripts/
sudo cp /opt/seagate/cortx/provisioner/files/etc/sysconfig/network-scripts/ifcfg-mgmt0 /etc/sysconfig/network-scripts/
sudo cp /opt/seagate/cortx/provisioner/files/etc/sysconfig/network-scripts/ifcfg-data0 /etc/sysconfig/network-scripts/
echo IPADDR=#{node["mgmt0"]}
echo IPADDR=#{node["data0"]}
sudo sed -i 's/IPADDR=/IPADDR=#{node["mgmt0"]}/g' /etc/sysconfig/network-scripts/ifcfg-mgmt0
sudo sed -i 's/IPADDR=/IPADDR=#{node["data0"]}/g' /etc/sysconfig/network-scripts/ifcfg-data0
sudo ifdown enp0s8
sudo ifdown enp0s9
sudo ifdown data0
sudo ifdown mgmt0
sudo ifup data0
sudo ifup mgmt0
touch /etc/salt/minion_id
echo #{node["minion_id"]} |tee /etc/salt/minion_id
sudo systemctl restart salt-minion
SHELL
#unless 's3client' == node['name']
# node_config.vm.provision :salt do |salt|
# # Master/Minion specific configs.
# salt.masterless = true
# salt.minion_config = './srv/components/provisioner/salt_minion/files/minion'
#
# # Generic configs
# salt.install_type = 'stable'
# salt.run_highstate = false
# salt.colorize = true
# salt.log_level = 'warning'
# end # End of Salt Provisioning
#end # End of Unless
end
end
end