From 6c51f510fabfb1b53bc35ab804b7772d94236cee Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 23 Aug 2018 11:51:05 -0400 Subject: [PATCH] Assign vagrant configuration by project root --- box/Vagrantfile | 9 ++++++--- provisioning/box/config.yml | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/box/Vagrantfile b/box/Vagrantfile index 6498282..19db24e 100644 --- a/box/Vagrantfile +++ b/box/Vagrantfile @@ -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') diff --git a/provisioning/box/config.yml b/provisioning/box/config.yml index 89be9ab..e482756 100644 --- a/provisioning/box/config.yml +++ b/provisioning/box/config.yml @@ -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 /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