Skip to content

Commit

Permalink
Allow vagrant directory location to be configurable (#10718)
Browse files Browse the repository at this point in the history
In the case were vagrant is not invoked directly from the repository,
but from another location, and the Vagrantfile is "included" into
another, we need to be able to specify where the location of the vagrant
directory is, as of now it's hardcoded relative to the Vagrantfile
location. This commit fix it.
  • Loading branch information
kri5 authored Jan 22, 2024
1 parent 0e971a3 commit fd6bb0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ $libvirt_nested ||= false
$ansible_verbosity ||= false
$ansible_tags ||= ENV['VAGRANT_ANSIBLE_TAGS'] || ""

$vagrant_dir ||= File.join(File.dirname(__FILE__), ".vagrant")

$playbook ||= "cluster.yml"

host_vars = {}
Expand All @@ -96,7 +98,7 @@ $inventory = File.absolute_path($inventory, File.dirname(__FILE__))
# if $inventory has a hosts.ini file use it, otherwise copy over
# vars etc to where vagrant expects dynamic inventory to be
if ! File.exist?(File.join(File.dirname($inventory), "hosts.ini"))
$vagrant_ansible = File.join(File.dirname(__FILE__), ".vagrant", "provisioners", "ansible")
$vagrant_ansible = File.join(File.absolute_path($vagrant_dir), "provisioners", "ansible")
FileUtils.mkdir_p($vagrant_ansible) if ! File.exist?($vagrant_ansible)
$vagrant_inventory = File.join($vagrant_ansible,"inventory")
FileUtils.rm_f($vagrant_inventory)
Expand Down

0 comments on commit fd6bb0f

Please sign in to comment.