Skip to content

Commit

Permalink
Fixes #1605: Randomize DrupalVM IP address.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Jun 5, 2017
1 parent f2115b3 commit 9794a67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/drupal-vm/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/Robo/Commands/Vm/VmCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9794a67

Please sign in to comment.