Setting environment variables for the project - Only-Smiles/DevOps-2025 GitHub Wiki
Last updated: 01.03.2025
Right now our Droplet has been built and deployed using vagrant up
. Our droplet should never have to be destroyed and built again during the course, but it might happen that we will have to do so, for some reasons unknown at this point in time.
In order to be able to build the Vagrantfile, the developer must set the following environment variables.
SSH_KEY_NAME
DIGITAL_OCEAN_TOKEN
PRIVATE_KEY_PATH
This section serves to provide a guide on how to do so.
SSH_KEY_NAME
This is the name of your own ssh_key, that you should add to our Team DigitalOcean project. Follow the steps below:
- Navigate to our Digital Ocean Project.
- In the left tab, scroll down to Settings
- Navigate to Security
- Click Add SSH key
- Copy your public ssh key and give it a key name.
The name of the key, is the environment variable that you need to set. For example, for Rakul, the name is rakul_ssh_key
:
Now set the environment variable in your system. (I only know how to do it for Mac, otherwise maybe google a bit (sry Daniel).
Navigate to the ~/.zrch
file and add the following to the file, replacing <NAME_OF_YOUR_SSH_KEY>
with the name you chose for the key.
export SSH_KEY_NAME="<NAME_OF_YOUR_SSH_KEY>"
Save the changes and exit.
DIGITAL_OCEAN_TOKEN
You need to create a Digital Ocean Token to our Team DigitalOcean project and store it on your laptop.
- Navigate to our Digital Ocean Project.
- In the left tab, scroll down to API
- Under Tokens > Personal Access Tokens, click Generate New Token
- Give the token a name, for example
rakul_do_token
- Make sure to set the Scopes to Full Access
- Scroll down and click Generate Token
- Copy the token
This will generate a long token, something like dop_v1_291337a3.....
. Make sure to copy the token to the clipboard.
You should now see something like this on the Digital Ocean page:
Now, as before, we have to set the environment variable in the system. Navigate to the ~/.zrch
file and add the following to the file, replacing <COPY_OF_YOUR_DIGITAL_OCEAN_TOKEN>
with the token that you copied just before.
export DIGITAL_OCEAN_TOKEN="<COPY_OF_YOUR_DIGITAL_OCEAN_TOKEN>"
Save the changes and exit.
PRIVATE_KEY_PATH
Finally we need to set the path to our private_key
. This should be located somewhere under ~/.ssh
. You might have multiple keys, so make sure that you choose the path to the private key, which 'belongs' to the public key that you previously added in our Team DigitalOcean project. I.e. if you added personal-user.pub
to the project before, you need to use the personal-user
public key.
Again, set the environment variable by navigating to the ~/.zrch
file and add the following to the file, replacing <PATH_TO_YOUR_PRIVATE_KEY>
with the actual path to your private key.
export PRIVATE_KEY_PATH='<PATH_TO_YOUR_PRIVATE_KEY>
For example, for Rakul it looks like this:
export PRIVATE_KEY_PATH='~/.ssh/personal-user'
Verifying that it works
To save and sync the changes that you just made, run source ~/.zshrc
in your terminal. Now you should be able to verify that it works by running the following three commands from your terminal. Each of them should output the value that you set in your .zrch
file
echo $PRIVATE_KEY_PATH
echo $DIGITAL_OCEAN_TOKEN
echo $SSH_KEY_NAME