Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 19, 2021 09:12 pm GMT

How to automate Open edX deployments using Github Actions

Introduction

What is Open edX ?

Open edX is an open-source platform you can use to create and host online courses. It was originally developed in 2012 by MIT and Harvard University and has since been adopted by organizations of all shapes and sizes to power a wide range of online learning use cases.
It has been used by organizations and universities like Microsoft, IBM, MIT, and ASU.

How do we handle deployments by default in Open edX ?

We use Ansible to provision and maintain our platform. If you are not familiar with Ansible, it's an open source Devops tool that automates the software provisioning and configuration. It building blocks are:

  • Ansible Playbooks which has 1 or multiple roles. Imaging Playbook as full instructions on how to install your software, it's components and how the set them up to work properly.
  • Ansible Roles. Each component in your stack has it's own role. for example if your are using Django, Nginx and MySQL in your application, each one of them has it's own role.
  • Variables. Each role has it's own variables. For example you should provide variables for MySQL role to define root username and password.

What is the workflow to change a variable ?

We have our playbooks, roles and their variables in a GitHub repo. Variables are divided to 2 different files vars.yml and passwords.yml. Passwords file is encrypted using Ansible Vault.
To change a variable and deploy it to the Open edX server we need to:
1- Pull the Github repo that has Open edX variables on a local machone
2- Change one or multiple variables
3- Push the changes back to the Github repo
4- Deploy new variables to the server from an Ansible Control node. Here we pass new vars.yml and passwords.yml to ansible-playbook command, Something like:

ansible-playbook /edx/app/edx_ansible/edx_ansible/playbooks/openedx_native.yml --vault-password-file ~/.ansible_vault_pass.txt -i ./ansible-configs/inventory -e@./edx-configs/vars.yml -e@./edx-configs/passwords.yml

Default Deployment Workflow

My Workflow

How GitHub actions can help to automate manual deployments

Problem
Steps 3 and 4 are where things can get complicated. As you see in the previous diagram these steps are manual and it can become really time consuming and tedious if you need to make multiple deployments to the same server or even to a cluster of servers.
Solution
Ideal solution will be to trigger new deployment to our server or servers as as soon as we push a new change to the GitHub repo. GitHub actions can do that for us. We can create a workflow that

  • Checks out our repo in a job
    • Using actions/checkout@v2 action
  • Install Ansible and all necessary libraries for a deployment
  • Installs Open edX SSH key in it and adds it's key as known host
    • Using shimataro/ssh-key-action@v2 action
  • Deploys new variables using Ansible
  • Restart all the services in Open edX to apply changesGithub Actions Workflow

Let's See how it works

One of the variables in the vars.yml file is EDXAPP_PLATFORM_NAME and we use it's value in template in multiple places like the footer.
Footer
Now let's change it's value to Cubite Technologies and commit the change. It should trigger GitHub action to deploy this new value to our server via Ansible.

Submission Category:

  • Maintainer Must-Haves
  • DIY Deployments

Yaml File or Link to Code

GitHub logo cubitetech / openedx-actions-demo

Repo to show how we can automate Open edX deployment using Github Actions

Additional Resources / Info

To learn more about Open edX check their website


Original Link: https://dev.to/corpcubite/how-to-automate-open-edx-deployments-using-github-actions-397l

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To