Assign vagrant configuration by project root

This commit is contained in:
Chris Thompson 2018-08-23 11:51:05 -04:00
parent 87e34788c8
commit 6c51f510fa
2 changed files with 12 additions and 7 deletions

9
box/Vagrantfile vendored
View file

@ -42,12 +42,15 @@ Vagrant.require_version ">= #{vconfig['drupalvm_vagrant_version_min']}"
ensure_plugins(vconfig['vagrant_plugins'])
# Acquire a hostname from the project root
vm_hostname = File.basename(ENV['DRUPALVM_PROJECT_ROOT']).gsub("_", "-")
Vagrant.configure('2') do |config|
# Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134
config.vm.define vconfig['vagrant_machine_name']
config.vm.define "#{vm_hostname}.local" #vconfig['vagrant_machine_name']
# Networking configuration.
config.vm.hostname = vconfig['vagrant_hostname']
# Networking configuration
config.vm.hostname = "#{vm_hostname}-coop-vm" #vconfig['vagrant_hostname']
config.vm.network :private_network,
ip: vconfig['vagrant_ip'],
auto_network: vconfig['vagrant_ip'] == '0.0.0.0' && Vagrant.has_plugin?('vagrant-auto_network')

View file

@ -9,10 +9,12 @@
vagrant_box: geerlingguy/debian9
# If you need to run multiple instances of Drupal VM, set a unique hostname,
# and machine name
vagrant_hostname: agaric.local
vagrant_machine_name: agaric-com-vm
# These variables are no longer honored. In order to use them specifically,
# revert the changes to use vconfig values in <project_root>/box/Vagrant
# And disable the pre-tasks
# vagrant_hostname: drutopia.local
# vagrant_machine_name: drutopia-com-vm
# You can specify an IP, or else the vagrant-auto_network will set it for you:
vagrant_ip: 0.0.0.0