Skip to content

Devops code structure

Kiran G edited this page Oct 16, 2017 · 10 revisions

Ansible Structure

Sunbird devops is split across two repositories.

Ansible Inventory structure

Following inventory structure is used:

`-- inventories
    `-- {env}  #name of the environment
    |   `-- group_vars
    |   |   `-- {env}-es.yml  # ES specific variables
    |   |   `-- ...
    |   |   `-- ...
    |   |   `-- {env}.yml  # Variables
    |   `-- hosts  # Ansible inventory definition
    |   `-- secrets.yml  # Secrets, encrypted using Ansible vault

Default values for variables should be put in {role}/defaults/main.yml.

Deployment Pipeline scripts

  • Sunbird environments are managed using Jenkins.
  • Pipeline scripts for various tasks ranging from deployment, taking DB backups to purging old logs, etc.
  • This wiki explains how the Sunbird CI pileline has been setup using Jenkins.

Service deploy script flow

Image: Edit Link

Sunbird service deployment happens as follows:

  • When a service deployment is triggered, Jenkins slave runs the corresponding ansible playbook.
  • The playbook connects to Docker swarm manager over SSH.
  • It then creates the necessary configs, secrets, stack files to deploy the service.
  • Runs stack deploy.
  • The stack deploy will start the corresponding service in Docker swarm agents as per the stack definition (image, replications, resource constraints, etc).

Custom images

  • Custom images of open-source libraries/tools – like nginx, kong, etc – are present in images directory.
  • Customizing an image involved the following (illustration uses the sunbird proxy image created using nginx):
    • Dockerfile: Defines how the image should be built.
    • Jenkinsfile.build: Jenkins pipeline script which uses the docker file to build the image and upload it to docker hub.
    • Jenkinsfile.silver: Jenkins pipeline script which tags the specified version of the image as silver.
    • Jenkinsfile.gold: Jenkins pipeline script which tags the specified version of the image as gold.
Clone this wiki locally