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']) 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| Vagrant.configure('2') do |config|
# Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134 # 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. # Networking configuration
config.vm.hostname = vconfig['vagrant_hostname'] config.vm.hostname = "#{vm_hostname}-coop-vm" #vconfig['vagrant_hostname']
config.vm.network :private_network, config.vm.network :private_network,
ip: vconfig['vagrant_ip'], ip: vconfig['vagrant_ip'],
auto_network: vconfig['vagrant_ip'] == '0.0.0.0' && Vagrant.has_plugin?('vagrant-auto_network') 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 vagrant_box: geerlingguy/debian9
# If you need to run multiple instances of Drupal VM, set a unique hostname, # These variables are no longer honored. In order to use them specifically,
# and machine name # revert the changes to use vconfig values in <project_root>/box/Vagrant
vagrant_hostname: agaric.local # And disable the pre-tasks
vagrant_machine_name: agaric-com-vm # 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: # You can specify an IP, or else the vagrant-auto_network will set it for you:
vagrant_ip: 0.0.0.0 vagrant_ip: 0.0.0.0