28
loading...
This website collects cookies to deliver better user experience
$ANSIBLE_VAULT;1.1;AES256
61353035366436396262643237303063643839653630393261663234666461653566626130613562
.
.
.
lms.yml
and it contains all the environment variables for our Learning Management System, for example:EMAIL_BACKEND: django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST: smtp.elasticemail.com
EMAIL_HOST_PASSWORD: ********
EMAIL_HOST_USER: ******
EMAIL_PORT: 2525
EMAIL_USE_TLS: true
lms.yml
on the server . One extra step to apply this change is to SSH to the server and restart all the services manually.openedx
with 3 environmentsEMAIL_HOST_PASSWORD
to manage the SMPT password. The value starts with aohRj******
This is not my real SMTP password it's only an exampleEMAIL_HOST_PASSWORD
from the local environment variables file it makes a call to Doppler API and gets the value for EMAIL_HOST_PASSWORD
. I added the following to our codebase in the edx-platform/lms/envs/production.py
file################################### Getting Environment Variables From Doppler ###################################
url = "https://api.doppler.com/v3/configs/config/secrets"
querystring = {"project": "openedx", "config": "dev"}
DOPPLER_TOKEN = AUTH_TOKENS.get('DOPPLER_TOKEN', '')
Authorization = "Basic {DOPPLER_TOKEN}".format(DOPPLER_TOKEN=DOPPLER_TOKEN)
headers = {
"Accept": "application/json",
"accepts": "application/json",
"Authorization": Authorization
}
doppler_response = requests.request("GET", url, headers=headers, params=querystring)
EMAIL_HOST_PASSWORD = doppler_response.json()['secrets']['EMAIL_HOST_PASSWORD']['raw']
EMAIL_HOST_PASSWORD = AUTH_TOKENS.get('EMAIL_HOST_PASSWORD', '')
from our code to prevent reading the value from local environment variables. >>> from django.conf import settings
>>> settings.EMAIL_HOST_PASSWORD
'aohRj******'
EMAIL_HOST_PASSWORD
sudo /edx/bin/supervisorctl restart all
to restart all the services to get up to date values for our secrets from Doppler. To remove this manual step we can use Doppler webhooks, so as soon as there is a change in one of our variables, we make a call to CircleCI to restart all the services in our server.doppler-openedx-deployer
. This project has a config.yml
file like following :version: 2
jobs:
build:
working_directory: ~/doppler-openedx-deployer
docker:
- image: circleci/python:3.6.4
steps:
- checkout
- run:
name: Deploy to Open edX
command: ~/doppler-openedx-deployer/scripts/deploy.sh
no_output_timeout: 30m
deploy.sh
we download the latest version of our Ansible Playbooks and it deploys a command to Open edX server to update configuration and restart all the services.