2021-11-26 15:05:45 +07:00
|
|
|
require 'yaml'
|
|
|
|
|
2022-01-02 14:02:09 +07:00
|
|
|
inventory = YAML.load_file(File.join(__dir__, './inventories/dev.yml'))
|
2021-12-01 22:53:46 +07:00
|
|
|
group_vars = YAML.load_file(File.join(__dir__, './group_vars/all.yml'))
|
2021-11-26 15:05:45 +07:00
|
|
|
|
2022-01-24 21:59:25 +07:00
|
|
|
# ANCHOR: vm_specs
|
2022-02-11 21:33:21 +07:00
|
|
|
cpus = 2
|
|
|
|
memory = "8192"
|
|
|
|
disk_size = "128GB"
|
2022-01-24 21:59:25 +07:00
|
|
|
# ANCHOR_END: vm_specs
|
|
|
|
|
2021-11-25 18:36:34 +07:00
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
config.vm.box = "rockylinux/8"
|
|
|
|
|
2022-01-02 14:02:09 +07:00
|
|
|
inventory['metal']['children'].each do |group, properties|
|
|
|
|
properties['hosts'].each do |host, host_vars|
|
|
|
|
config.vm.define host do |node|
|
|
|
|
ip = host_vars['ansible_host']
|
2022-01-02 15:38:04 +07:00
|
|
|
node.vm.network "public_network", ip: ip
|
2022-01-02 14:02:09 +07:00
|
|
|
node.vm.hostname = host
|
2022-01-24 21:59:25 +07:00
|
|
|
node.vm.disk :disk, size: disk_size, primary: true
|
2021-12-31 16:33:09 +07:00
|
|
|
end
|
2021-11-26 15:05:45 +07:00
|
|
|
end
|
2021-11-25 18:36:34 +07:00
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.provider "virtualbox" do |vb|
|
2022-01-24 21:59:25 +07:00
|
|
|
vb.cpus = cpus
|
|
|
|
vb.memory = memory
|
2021-11-25 18:36:34 +07:00
|
|
|
end
|
|
|
|
|
2022-01-02 14:02:09 +07:00
|
|
|
config.vm.provision "file",
|
|
|
|
source: "#{group_vars['ansible_ssh_private_key_file']}.pub",
|
|
|
|
destination: "/tmp/id_ed25519.pub"
|
|
|
|
|
|
|
|
# TODO move most of this to Ansible?
|
|
|
|
config.vm.provision "shell",
|
|
|
|
reboot: true,
|
|
|
|
inline: <<-SHELL
|
|
|
|
mkdir /#{group_vars['ansible_user']}/.ssh
|
|
|
|
cat /tmp/id_ed25519.pub >> ~#{group_vars['ansible_user']}/.ssh/authorized_keys
|
|
|
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
|
|
|
|
dnf install -y iscsi-initiator-utils
|
|
|
|
systemctl enable --now iscsid
|
|
|
|
sysctl fs.inotify.max_user_instances=8192
|
|
|
|
sysctl -p
|
|
|
|
SHELL
|
2021-11-25 18:36:34 +07:00
|
|
|
end
|