2019-09-18 02:32:08 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2023-08-21 22:46:47 +00:00
|
|
|
require 'yaml'
|
|
|
|
settings_path = '.vagrant.yml'
|
|
|
|
settings = {}
|
|
|
|
|
|
|
|
if File.exist?(settings_path)
|
|
|
|
settings = YAML.load_file(settings_path)
|
2021-04-15 06:43:24 +00:00
|
|
|
end
|
2021-03-13 07:44:30 +00:00
|
|
|
|
2023-08-21 22:46:47 +00:00
|
|
|
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'debian/bookworm64'
|
|
|
|
VAGRANT_CPUS = settings['VAGRANT_CPUS'] || 2
|
|
|
|
VAGRANT_MEM = settings['VAGRANT_MEM'] || 2048
|
|
|
|
SSH_FORWARD = settings['SSH_FORWARD'] || false
|
|
|
|
|
|
|
|
# Default to shell environment variable: PLAYBOOK (priority #1)
|
2021-04-15 06:43:24 +00:00
|
|
|
PLAYBOOK=ENV["PLAYBOOK"]
|
2023-08-30 23:45:42 +00:00
|
|
|
if !PLAYBOOK || PLAYBOOK.empty?
|
2023-08-21 22:46:47 +00:00
|
|
|
# PLAYBOOK setting in .vagrant.yml (priority #2)
|
2023-08-30 23:45:42 +00:00
|
|
|
PLAYBOOK = settings['PLAYBOOK'] || 'default'
|
2021-03-13 07:44:30 +00:00
|
|
|
end
|
|
|
|
|
2019-09-18 02:32:08 +00:00
|
|
|
Vagrant.configure("2") do |config|
|
2023-08-21 22:46:47 +00:00
|
|
|
config.vm.box = VAGRANT_BOX
|
2020-06-24 01:59:47 +00:00
|
|
|
config.vm.network "private_network", type: "dhcp"
|
2021-04-15 06:43:24 +00:00
|
|
|
config.ssh.forward_agent = SSH_FORWARD
|
2019-09-18 02:32:08 +00:00
|
|
|
|
2023-08-21 22:46:47 +00:00
|
|
|
# Libvrit provider
|
2019-09-18 02:32:08 +00:00
|
|
|
config.vm.provider :libvirt do |libvirt|
|
2023-08-21 22:46:47 +00:00
|
|
|
libvirt.cpus = VAGRANT_CPUS
|
|
|
|
libvirt.memory = VAGRANT_MEM
|
2019-09-18 02:32:08 +00:00
|
|
|
end
|
|
|
|
|
2023-08-21 22:46:47 +00:00
|
|
|
# Virtualbox provider
|
|
|
|
config.vm.provider :virtualbox do |vbox|
|
|
|
|
vbox.cpus = VAGRANT_CPUS
|
|
|
|
vbox.memory = VAGRANT_MEM
|
2024-05-02 05:37:26 +00:00
|
|
|
vbox.gui = true
|
2020-06-13 05:12:23 +00:00
|
|
|
end
|
|
|
|
|
2019-09-18 02:32:08 +00:00
|
|
|
# Provision with Ansible
|
|
|
|
config.vm.provision "ansible" do |ansible|
|
2020-06-15 02:33:39 +00:00
|
|
|
ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles"
|
2019-09-18 02:32:08 +00:00
|
|
|
ansible.compatibility_mode = "2.0"
|
2021-03-13 07:44:30 +00:00
|
|
|
ansible.playbook = "dev/" + PLAYBOOK + ".yml"
|
2024-05-02 05:37:26 +00:00
|
|
|
ansible.raw_arguments = ["--diff", "-vvv"]
|
2019-09-18 02:32:08 +00:00
|
|
|
end
|
|
|
|
end
|