# Provisioning step gets executed after folder syncing step
$provision_script = <<-SCRIPT
rc-service openntpd stop && rc-update del openntpd && apk del openntpd
apk add ansible-core grub
ansible-galaxy collection install -r /vagrant/requirements/collections.yml
mkdir -pv /vagrant/host_vars
echo \"vault_password: \'123456\'\" > /vagrant/host_vars/localhost.yml
SCRIPT

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
Vagrant.configure("2") do |config|
  config.vm.define :sysconfig do |sysconfig|
    sysconfig.vm.box = "generic/alpine315"

    sysconfig.vm.provider :libvirt do |libvirt|
      libvirt.cpus = 2
      libvirt.memory = 512

      # Use the default NAT network of libvirt
      libvirt.management_network_name = "default"
      libvirt.management_network_address = "192.168.122.0/24"
    end

    sysconfig.vm.provision "shell", inline: $provision_script

    sysconfig.vm.synced_folder ".", "/vagrant", type: "rsync",
      rsync__exclude: [".git/", "Vagrantfile", ".gitignore"]
  end
end
