Skip to content

Instantly share code, notes, and snippets.

@russellsmithies
Created August 10, 2023 03:12
Show Gist options
  • Save russellsmithies/aa986e6ebd15dda3c606d6ffe61524da to your computer and use it in GitHub Desktop.
Save russellsmithies/aa986e6ebd15dda3c606d6ffe61524da to your computer and use it in GitHub Desktop.
A Vagrantfile to create a small HTCondor cluster
# -*- mode: ruby -*-
# vi: set ft=ruby :
#Total number of nodes
NODE_COUNT = 5
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = 1024
vb.cpus = 2
vb.linked_clone = true
end
NODE_COUNT.times do |i|
node_id = "node#{i}"
ip_address = "10.10.10.#{i+3}"
config.vm.define node_id do |node|
node.vm.box = "geerlingguy/rockylinux8"
node.vm.hostname = "#{node_id}"
node.vm.network :private_network, ip: "#{ip_address}"
# append all the nodes to /etc/hosts
NODE_COUNT.times do |j|
ipa = "10.10.10.#{j+3}"
nid = "node#{j}"
node.vm.provision "shell",
args: [ "#{ipa}", "#{nid}" ],
inline: "echo \"$1 $2\" >> /etc/hosts"
end
# remove stupid message on login
node.vm.provision "shell",
inline: "rm -f /etc/issue.d/cockpit.issue /etc/motd.d/cockpit"
#HTCondor params for installing the services
#The first node is the controller
htcondor_controller = "node0"
htcondor_password = "areallysecurepassword"
if node.vm.hostname == "#{htcondor_controller}"
node.vm.provision "shell",
args: ["#{htcondor_password}", "#{htcondor_controller}"],
inline: <<-SHELL
curl -fsSL https://get.htcondor.org | sed -e 's/do_configure_firewall //' | \
GET_HTCONDOR_PASSWORD=$1 /bin/bash -s -- --no-dry-run --central-manager $2
cat /etc/condor/config.d/01-central-manager.config | sed -e 's/get_htcondor_central_manager/get_htcondor_execute/' > /etc/condor/config.d/01-execute.config
cat /etc/condor/config.d/01-central-manager.config | sed -e 's/get_htcondor_central_manager/get_htcondor_submit/' > /etc/condor/config.d/01-submit.config
systemctl enable --now condor
SHELL
else
node.vm.provision "shell",
args: ["#{htcondor_password}", "#{htcondor_controller}"],
inline: <<-SHELL
curl -fsSL https://get.htcondor.org | sed -e 's/do_configure_firewall //' | \
GET_HTCONDOR_PASSWORD=$1 /bin/bash -s -- --no-dry-run --execute $2
cat /etc/condor/config.d/01-execute.config | sed -e 's/get_htcondor_execute/get_htcondor_submit/' > /etc/condor/config.d/01-submit.config
systemctl enable --now condor
SHELL
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment