I'm running Vagrant 1.8.5, which supports environment variables in the Vagrantfile at provisioning time using a format like this
config.vm.provision :shell, path: "bootstrap.sh", env: {"MYSQL_DB_USERNAME"=>"django", "MYSQL_DB_PASSWORD"=>"supersecretpasswordwasreplaced"}
However, I would like these environment variables to also be available when I do up
without provisioning, or when I SSH into the server to do jobs. The obvious ways I can find are
- to have them built into the box (seems like overkill) or
- repeat them in my
config.ssh.forward_env
so that they are available to both the provisioner and SSH.
Is there a better way?
I am not sure about the best ultimate way - I've seen this question popping from time to time and discussion.
well, it could sound like a good solution but there's some drawback, I've discussed in this question already
Personally when I need to set env variable, I would add them in the
.profile
file:They will be available when you login.
At first glance, this answer seems similar to the top voted answer. However, please look carefully at the redirection operator on the second
echo