Created
February 12, 2019 07:44
-
-
Save rvanbutselaar/1c39c33d2132aced77ecf8da24c4f14e to your computer and use it in GitHub Desktop.
Vagrantfile with additional disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# | |
# cpu = # cpu per VM | |
cpu = 3 | |
# | |
# mem = MB ram per VM | |
# | |
mem = 4096 | |
# | |
# Do not update guest utils on vms | |
# | |
# vbguest_auto_update = false | |
# | |
# project name will be used to generate hostnames: <project#{node_nr}> | |
# | |
project = 'rhel' | |
# | |
# Check if config needs to be generated | |
# | |
if ARGV[0] == 'up' || ARGV[0] == 'reload' | |
update_config = true | |
end | |
vagrant_root = File.dirname(__FILE__) | |
Vagrant.configure(2) do |config| | |
# | |
# vm specs | |
# | |
config.vm.provider "virtualbox" do |v| | |
v.memory = mem | |
v.cpus = cpu | |
v.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--controller', 'IntelAHCI'] | |
file_to_disk = '$vagrant_root/disk2.vdi' | |
unless File.exist?(file_to_disk) | |
v.customize ['createhd', '--filename', file_to_disk, '--size', 50 * 1024] # 50 GB | |
end | |
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 0, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] | |
file_to_disk = '$vagrant_root/disk3.vdi' | |
unless File.exist?(file_to_disk) | |
v.customize ['createhd', '--filename', file_to_disk, '--size', 50 * 1024] # 50 GB | |
end | |
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] | |
end | |
# | |
# Use insecure key | |
config.ssh.insert_key = false | |
# | |
# | |
# Configre private_ip as hostname | |
# | |
config.hostmanager.enabled = true | |
config.hostmanager.manage_host = true | |
config.hostmanager.manage_guest = true | |
config.hostmanager.ignore_private_ip = false | |
# | |
# M = total masters to create | |
# N = total nodes to create | |
# | |
N = 1 | |
# | |
# Local username | |
# | |
$local_username ||= `whoami` | |
# | |
# Create master nodes | |
# | |
(1..N).each do | node_nr | | |
hostname = project + "-master#{node_nr}" | |
random_ssh_port = (30000..65534).to_a.sample | |
random_http_port = (30000..65534).to_a.sample | |
random_https_port = (30000..65534).to_a.sample | |
config.vm.define hostname do | node | | |
# node.vbguest.auto_update = vbguest_auto_update | |
node.vm.box = 'generic/rhel7' | |
node.vm.hostname = hostname | |
node.vm.network :forwarded_port, guest: 22, host: random_ssh_port, id: "ssh" | |
node.vm.network :forwarded_port, guest: 80, host: random_http_port, id: "http" | |
node.vm.network :forwarded_port, guest: 443, host: random_https_port, id: "https" | |
node.vm.network "forwarded_port", guest: 8443, host: 8443 | |
node.vm.network "private_network", ip: "10.0.0.11#{node_nr}" | |
# | |
# Provision VMs using shell | |
# | |
node.vm.provision :shell, :path => "prepare-install.sh" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment