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
|
|
|
|
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
|
|
|
|
node.vm.disk :disk, size: "256GB", 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-02 14:02:09 +07:00
|
|
|
# TODO this is ridiculous for a local environment, optimize it
|
2021-12-12 00:23:55 +07:00
|
|
|
vb.cpus = 6
|
|
|
|
vb.memory = "10240"
|
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
|