From 9794a67633cc5f8a0b3d44147f4bb95ccec8ca80 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 5 Jun 2017 16:42:31 -0400 Subject: [PATCH] Fixes #1605: Randomize DrupalVM IP address. --- scripts/drupal-vm/config.yml | 2 +- src/Robo/Commands/Vm/VmCommand.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/drupal-vm/config.yml b/scripts/drupal-vm/config.yml index 224ae7ba82..625f482807 100644 --- a/scripts/drupal-vm/config.yml +++ b/scripts/drupal-vm/config.yml @@ -3,7 +3,7 @@ vagrant_hostname: ${project.local.hostname} vagrant_machine_name: ${project.machine_name} # Set the IP address so it doesn't conflict with other Drupal VM instances. -vagrant_ip: 192.168.25.8 +vagrant_ip: ${random.ip} # Use Ubuntu 14.04 LTS to more closely match Acquia Cloud environment. vagrant_box: geerlingguy/ubuntu1404 diff --git a/src/Robo/Commands/Vm/VmCommand.php b/src/Robo/Commands/Vm/VmCommand.php index 84a81d2cb6..f2339708f6 100644 --- a/src/Robo/Commands/Vm/VmCommand.php +++ b/src/Robo/Commands/Vm/VmCommand.php @@ -139,7 +139,12 @@ public function config() { ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE) ->run(); - $this->getConfig()->expandFileProperties($this->projectDrupalVmConfigFile); + // Generate a Random IP address for the new VM. + $config = clone $this->getConfig(); + $random_local_ip = "192.168." . rand(0, 255) . '.' . rand(0, 255); + $config->set('random.ip', $random_local_ip); + + $config->expandFileProperties($this->projectDrupalVmConfigFile); $vm_config = Yaml::parse(file_get_contents($this->projectDrupalVmConfigFile)); $this->validateConfig($vm_config);