mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-05 21:11:52 +07:00
34 lines
983 B
Ruby
34 lines
983 B
Ruby
# require 'ipaddr' # TODO dynamic IP based on inventory
|
|
require 'yaml'
|
|
|
|
ip_prefix = '192.168.1.'
|
|
group_vars = YAML.load_file(File.join(__dir__, './group_vars/all.yml'))
|
|
|
|
Vagrant.configure("2") do |config|
|
|
config.vm.box = "rockylinux/8"
|
|
|
|
node_count = 1
|
|
|
|
(0..(node_count-1)).each do |i|
|
|
config.vm.define "dev#{i}" do |dev|
|
|
dev.vm.network "public_network", ip: "#{ip_prefix}#{200+i+1}"
|
|
dev.vm.hostname = "dev#{i}"
|
|
dev.vm.disk :disk, size: "128GB", primary: true
|
|
end
|
|
end
|
|
|
|
config.vm.provider "virtualbox" do |vb|
|
|
vb.cpus = 4
|
|
vb.memory = "8192"
|
|
end
|
|
|
|
config.vm.provision "file", source: "#{group_vars['ansible_ssh_private_key_file']}.pub", destination: "/tmp/id_ed25519.pub"
|
|
|
|
config.vm.provision "shell", inline: <<-SHELL
|
|
mkdir /#{group_vars['ansible_user']}/.ssh
|
|
cat /tmp/id_ed25519.pub >> /#{group_vars['ansible_user']}/.ssh/authorized_keys
|
|
dnf install -y iscsi-initiator-utils
|
|
systemctl enable --now iscsid
|
|
SHELL
|
|
end
|