128 lines
4.7 KiB
Ruby
128 lines
4.7 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
|
|
# Configure a new SSH key and config so the operator is able to connect with
|
|
# the other cluster nodes.
|
|
if not File.file?("./vagrantkey")
|
|
system("ssh-keygen -f ./vagrantkey -N '' -C this-is-vagrant")
|
|
end
|
|
|
|
Vagrant.configure(2) do |config|
|
|
# The base image to use
|
|
# TODO (harmw): something more close to vanilla would be nice, someday.
|
|
config.vm.box = "puppetlabs/centos-7.0-64-puppet"
|
|
|
|
# Next to the hostonly NAT-network there is a host-only network with all
|
|
# nodes attached. Plus, each node receives a 3rd adapter connected to the
|
|
# outside public network.
|
|
# TODO (harmw): see if there is a way to automate the selection of the bridge
|
|
# interface.
|
|
config.vm.network "private_network", type: "dhcp"
|
|
config.vm.network "public_network", ip: "0.0.0.0", bridge: "wlp3s0b1"
|
|
|
|
my_privatekey = File.read(File.join(File.dirname(__FILE__), "vagrantkey"))
|
|
my_publickey = File.read(File.join(File.dirname(__FILE__), "vagrantkey.pub"))
|
|
|
|
config.vm.provision :shell, inline: <<-EOS
|
|
mkdir -p /root/.ssh
|
|
echo '#{my_privatekey}' > /root/.ssh/id_rsa
|
|
chmod 600 /root/.ssh/id_rsa
|
|
echo '#{my_publickey}' > /root/.ssh/authorized_keys
|
|
chmod 600 /root/.ssh/authorized_keys
|
|
mkdir -p /home/vagrant/.ssh
|
|
echo '#{my_privatekey}' >> /home/vagrant/.ssh/id_rsa
|
|
chmod 600 /home/vagrant/.ssh/*
|
|
echo 'Host *' > ~vagrant/.ssh/config
|
|
echo StrictHostKeyChecking no >> ~vagrant/.ssh/config
|
|
chown -R vagrant: /home/vagrant/.ssh
|
|
EOS
|
|
|
|
config.hostmanager.enabled = true
|
|
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
|
|
if vm.id
|
|
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
|
|
end
|
|
end
|
|
|
|
# The operator controls the deployment
|
|
config.vm.define "operator" do |admin|
|
|
admin.vm.hostname = "operator.local"
|
|
admin.vm.provision :shell, path: "bootstrap.sh", args: "operator"
|
|
admin.vm.synced_folder "storage/operator/", "/data/host", create:"True"
|
|
admin.vm.synced_folder "storage/shared/", "/data/shared", create:"True"
|
|
admin.vm.synced_folder ".", "/vagrant", disabled: true
|
|
admin.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 1024
|
|
end
|
|
admin.hostmanager.aliases = "operator"
|
|
end
|
|
|
|
# Build compute nodes
|
|
(1..1).each do |i|
|
|
config.vm.define "compute0#{i}" do |compute|
|
|
compute.vm.hostname = "compute0#{i}.local"
|
|
compute.vm.provision :shell, path: "bootstrap.sh"
|
|
compute.vm.synced_folder "storage/compute/", "/data/host", create:"True"
|
|
compute.vm.synced_folder "storage/shared/", "/data/shared", create:"True"
|
|
compute.vm.synced_folder ".", "/vagrant", disabled: true
|
|
compute.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 1024
|
|
end
|
|
compute.hostmanager.aliases = "compute0#{i}"
|
|
end
|
|
end
|
|
|
|
# Build storage nodes
|
|
(1..1).each do |i|
|
|
config.vm.define "storage0#{i}" do |storage|
|
|
storage.vm.hostname = "storage0#{i}.local"
|
|
storage.vm.provision :shell, path: "bootstrap.sh"
|
|
storage.vm.synced_folder "storage/storage/", "/data/host", create:"True"
|
|
storage.vm.synced_folder "storage/shared/", "/data/shared", create:"True"
|
|
storage.vm.synced_folder ".", "/vagrant", disabled: true
|
|
storage.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 1024
|
|
end
|
|
storage.hostmanager.aliases = "storage0#{i}"
|
|
end
|
|
end
|
|
|
|
# Build network nodes
|
|
(1..1).each do |i|
|
|
config.vm.define "network0#{i}" do |network|
|
|
network.vm.hostname = "network0#{i}.local"
|
|
network.vm.provision :shell, path: "bootstrap.sh"
|
|
network.vm.synced_folder "storage/network/", "/data/host", create:"True"
|
|
network.vm.synced_folder "storage/shared/", "/data/shared", create:"True"
|
|
network.vm.synced_folder ".", "/vagrant", disabled: true
|
|
network.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 1024
|
|
end
|
|
network.hostmanager.aliases = "network0#{i}"
|
|
end
|
|
end
|
|
|
|
# Build control nodes
|
|
(1..3).each do |i|
|
|
config.vm.define "control0#{i}" do |control|
|
|
control.vm.hostname = "control0#{i}.local"
|
|
control.vm.provision :shell, path: "bootstrap.sh"
|
|
control.vm.synced_folder "storage/control/", "/data/host", create:"True"
|
|
control.vm.synced_folder "storage/shared/", "/data/shared", create:"True"
|
|
control.vm.synced_folder ".", "/vagrant", disabled: true
|
|
control.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 2048
|
|
end
|
|
control.hostmanager.aliases = "control0#{i}"
|
|
|
|
# TODO: Here we bind local port 8080 to Horizon on control01 only.
|
|
# TODO: Once we implement Horizon behind a VIP, this obviously needs to
|
|
# be changed.
|
|
#if i < 2 then
|
|
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
|
#end
|
|
end
|
|
end
|
|
|
|
end
|