Devops code structure - project-sunbird/sunbird-devops GitHub Wiki
Ansible Structure
Sunbird devops is split across two repositories.
- Public repo
- Ansible roles.
- Ansible playbooks.
- Simple deployment scripts.
- Docker Image scripts.
- Azure ACS engine scripts which help in setting up Docker swarm on Azure.
- Private repo
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
images/Sunbird service deploy script flow.png
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 assilver
.Jenkinsfile.gold
: Jenkins pipeline script which tags the specified version of the image asgold
.