Your way of altering `vagrant up´ won't work. The correct way of doing this is during provisioning. Depending on the provisioner you are using, there are different ways.
Here is an example how to echo your host PATH env on your guest during provisioning:
config.vm.provision "shell", inline: "echo " + ENV['PATH']
As you can see, inside your Vagrantfile you can use the ENV
variable to access the host environment variables. You can use this to pass variables to the provisioner of your choice and processing it as needed.
As I'm most used to chef, here is how I would do it:
- Pass all ENV variables needed through Vagrantfile into some chef attributes
- Create a template which iterates over the values provided and writes export statements
- Use chef to put this template into
/etc/profile.d/
under some name that fits the needs