Create linux environment variable using vagrant provisioner
vagrant
Solution
You should have the provisioning script add a line to your .profile:
echo "export VAR=value" >> ~/.profile
On login, the .profile script will be read by bash and the variable will be set.
Problem
I've got vagrant running Ubuntu for development purposes. I've used a shell script provisioner to download/install my dependencies and create some aliases, but I've hit a wall in terms of using the provisioner to create environment variables (which are used for several flags within my project). Originally I had something like: ``` export MY_VAR='value' ``` Into my provisioner script, but then found out that you can't add environment variables from inside a shell script by running it normally. Fair enough, so I tried instead changing my line of the Vagrantfile to: ``` config.vm.provision "shell", inline: “source setup.sh" ``` Which didn't solve the problem. Environment variables still weren't there. I tried adding the exports directly as an inline: ``` config.vm.provision "shell", inline: “export MY_VAR='value'" ``` No luck. Still no global environment when I ssh'ed in. Is there a way to use the shell script to set a bash environment variable, or is it time to throw in the towel on shell provisioners and learn chef?