Enhanced variable handling
- Load variables from .vagrant_settings - Provide default values
This commit is contained in:
parent
b3e232451c
commit
f68117d9a0
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.vagrant
|
||||
.vagrant_settings
|
||||
.vscode
|
||||
|
34
Vagrantfile
vendored
34
Vagrantfile
vendored
@ -1,12 +1,34 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Load overrides
|
||||
require 'yaml'
|
||||
settings_path = '.vagrant_settings'
|
||||
settings = {}
|
||||
|
||||
if File.exist?(settings_path)
|
||||
settings = YAML.load_file(settings_path)
|
||||
end
|
||||
|
||||
VAGRANT_CPUS = settings["VAGRANT_CPUS"] || 2
|
||||
VAGRANT_MEMORY = settings["VAGRANT_MEMORY"] || 4096
|
||||
VAGRANT_NETWORK_NAME = settings["VAGRANT_NETWORK_NAME"] || "vagrant-libvirt"
|
||||
VAGRANT_NETWORK_ADDR = settings["VAGRANT_NETWORK_ADDR"] || "192.168.121.0/24"
|
||||
|
||||
# Vagrant
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "debian/bookworm64"
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
# Libvrit settings
|
||||
config.vm.provider :libvirt do |domain|
|
||||
domain.memory = 4096
|
||||
domain.cpus = 2
|
||||
# Libvirt settings
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpu_mode = "host-model"
|
||||
libvirt.cpus = VAGRANT_CPUS
|
||||
libvirt.memory = VAGRANT_MEMORY
|
||||
libvirt.management_network_name = VAGRANT_NETWORK_NAME
|
||||
libvirt.management_network_address = VAGRANT_NETWORK_ADDR
|
||||
libvirt.nested = true
|
||||
end
|
||||
|
||||
# Boot with a GUI in VirtualBox
|
||||
@ -14,8 +36,8 @@ Vagrant.configure("2") do |config|
|
||||
vbox.customize ["modifyvm", :id, "--vram", "128",
|
||||
"--graphicscontroller", "vboxvga",
|
||||
"--accelerate3d", "on"]
|
||||
vbox.memory = 4096
|
||||
vbox.cpus = 2
|
||||
vbox.memory = VAGRANT_MEMORY
|
||||
vbox.cpus = VAGRANT_CPUS
|
||||
vbox.gui = true
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user