Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
require 'yaml'

Vagrant.configure("2") do |config|
if Vagrant.has_plugin?('vagrant-hostmanager')
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.include_offline = true
end
config.vm.synced_folder ".", "/vagrant"

config.vm.provision("etc_hosts", type: 'ansible') do |ansible|
Expand All @@ -17,7 +25,7 @@ Vagrant.configure("2") do |config|
override.vm.provider "libvirt" do |libvirt, provider|
libvirt.memory = 10240
libvirt.cpus = 4
libvirt.machine_virtual_size = 30
libvirt.machine_virtual_size = 50
end
end

Expand All @@ -38,4 +46,23 @@ Vagrant.configure("2") do |config|
libvirt.memory = 2048
end
end

# Load user-local box definitions from boxes.yaml (gitignored)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me we should clean up the gitignore as it has some forklift-isms.

boxes_yaml = File.join(__dir__, 'boxes.yaml')
if File.exist?(boxes_yaml)
user_boxes = YAML.safe_load(File.read(boxes_yaml)) || {}
user_boxes.each do |name, settings|
next if settings.nil?
Comment on lines +54 to +55
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
user_boxes.each do |name, settings|
next if settings.nil?
user_boxes.compact.each do |name, settings|

config.vm.define name do |override|
override.vm.box = ENV.fetch("FOREMANCTL_BASE_BOX", settings.fetch('box', 'centos/stream9'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the order be reversed and have the settings take priority?

Suggested change
override.vm.box = ENV.fetch("FOREMANCTL_BASE_BOX", settings.fetch('box', 'centos/stream9'))
override.vm.box = settings.fetch('box') { ENV.fetch('FOREMANCTL_BASE_BOX', 'centos/stream9') }

override.vm.hostname = settings.fetch('hostname', "#{name}.example.com")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you rebase, please respect the Vagrant domain here.


override.vm.provider "libvirt" do |libvirt, _provider|
libvirt.memory = settings.fetch('memory', 4096)
libvirt.cpus = settings.fetch('cpus', 1)
libvirt.machine_virtual_size = settings['disk_size'] if settings.key?('disk_size')
end
end
end
end
end