Fakultas Ilmu Komputer UI

Commit 5dc6b169 authored by Ardhi Putra Pratama's avatar Ardhi Putra Pratama
Browse files

Add provision script

parent 1d7138b3
......@@ -4,7 +4,7 @@ Vagrant.require_version ">= 1.6.0"
# Defaults for config options defined in CONFIG
$num_instances = 3
$instance_name_prefix = "cl-ardhi"
$instance_name_prefix = "hpc-ardhi"
$enable_serial_logging = false
$share_home = true
$vm_gui = false
......@@ -12,12 +12,28 @@ $vm_memory = 3072
$vm_cpus = 2
$forwarded_ports = {}
$prov = <<SCRIPT
apt update
apt -y install sshpass build-essential libopenmpi-dev openmpi-bin openmpi-doc
sed -i 's/^PasswordAuthentication .*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd.service
SCRIPT
$prov_local = <<SCRIPT
touch me-$1.txt
touch total-$2.txt
echo -e 'n\n' | ssh-keygen -f .ssh/id_rsa -t rsa -N ''
SCRIPT
# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
$num_instances = ENV["NUM_INSTANCES"].to_i
end
# Use old vb_xxx config variables when set
def vm_gui
$vb_gui.nil? ? $vm_gui : $vb_gui
end
......@@ -39,6 +55,7 @@ Vagrant.configure("2") do |config|
# enable hostmanager
config.hostmanager.enabled = true
# configure the host's /etc/hosts
config.hostmanager.manage_host = true
......@@ -63,6 +80,9 @@ Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
end
# shared folder
config.vm.synced_folder "vhome/", "/vhome"
config.vm.provider :virtualbox do |vb|
vb.gui = vm_gui
vb.memory = vm_memory
......@@ -71,6 +91,10 @@ Vagrant.configure("2") do |config|
ip = "172.17.10.#{i+100}"
config.vm.network :private_network, ip: ip
config.vm.provision :"shell", inline: $prov
config.vm.provision :"shell", inline: $prov_local, args:"#{i} #{$num_instances}", privileged: false
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment