Search code examples
vagrantchef-infravagrantfilechef-solo

is there any way to get value of a vagrant autocorrect port forward in a script?


I'm using Vagrant and Chef-zero to deploy test servers and one of the attributes that the program I'm testing requires is it's service URL. With the following lines in my Vagrant file:

 config.vm.network :forwarded_port, guest: 80, host: 8000, auto_correct: true
 ...
 chef.json = {
  'pywps' => {
    :serverurl => 'http://localhost:8000/cgi-bin/wps.py',
    ...
    }
   }

Everything works fine for the first VM I spin up but if I need a second (or something is already using port 8000) then Vagrant auto corrects my port but I need some way to put that port number into the serverurl variable.

Is this possible?


Solution

  • AFAIK not off the shelf. You could make a Vagrant plugin to hook into the provisioning process and rewrite the data, but that is likely overkill.