From b56aadd22dda7ca00c67fd0c3aef35598224d847 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Sat, 27 Jan 2024 14:36:55 +0100 Subject: [PATCH] Use shorter directory names for beaker-hostgenerator When the Beaker setfile doesn't exist, Beaker calls beaker-hostgenerator and sets the :hosts_file_generated option. These directory names can become very long and in some cases exceed some limits when used with vagrant-libvirt. This only uses the hostnames and discards all options passed. This can break some scenarios where a host is reused and a user may assume that passing in new options changes the host. --- lib/beaker/hypervisor/vagrant.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/beaker/hypervisor/vagrant.rb b/lib/beaker/hypervisor/vagrant.rb index 6629a2e..3d75372 100644 --- a/lib/beaker/hypervisor/vagrant.rb +++ b/lib/beaker/hypervisor/vagrant.rb @@ -204,8 +204,12 @@ def initialize(vagrant_hosts, options) @options = options @logger = options[:logger] @hosts = vagrant_hosts - @vagrant_path = File.expand_path(File.join('.vagrant', 'beaker_vagrant_files', - 'beaker_' + File.basename(options[:hosts_file]))) + vagrant_directory = if options[:hosts_file_generated] + "beaker_hostgenerator_#{@hosts.map(&:name).join('-')}" + else + "beaker_#{File.basename(options[:hosts_file])}" + end + @vagrant_path = File.expand_path(File.join('.vagrant', 'beaker_vagrant_files', vagrant_directory)) @vagrant_file = File.expand_path(File.join(@vagrant_path, 'Vagrantfile')) @vagrant_env = {} end