How to get env var from one VM and pass it to another VM in Vagrantfile?

259 views Asked by At

Would like to create three VMs using Vagrantfile.

Provisioning for VM#1 (first in sequence) runs a shell script (inside the guest) which prints a secret-token. I would like to "automatically" (i.e. through Vagrantfile) retrieve that secret-token generated while provisioning VM1, and pass it as an argument to provisioning scripts of VM#2 and VM#3. Is this possible ? If so how ?

Please note that I can very well create the 3 VMs, but extracting the secret-token from VM1 (automatically i.e. in the process of running vagrant up) and passing it to provisioning logic of other VMs is all I am missing.

1

There are 1 answers

0
bdutta74 On

Apparently the above cannot be achieved, using environment variables directly but only by using files and file/exchange between guest and host. The methods are described in this SO answer.