Setup of DevOps pipeline
DevOps pipeline has the following main components.
- Jenkins Server
- Hashicorp Vault
- Docker Swarm (This could be your localhost as well)
- Database Server (This could be your localhost as well, same as Docker Swarm)
- Private Docker Registry
- Ansible
- Preferred OS environment is Linux, Setup is not tested on windows
Setup
- Install Jenkins
- Setup Hashicorp Vault
- Generate Unseal keys and vault token
- Install Docker
- Initialize Docker Swarm
- Docker swarm needs an external overlay network to be created. Create a network named
application_defaultin Docker
- Docker swarm needs an external overlay network to be created. Create a network named
- Install ansible on Docker Swarm and Database servers
- Setup Docker Registry
- Use the following compose for private registry setup.
version: '3' services: registry: image: registry:2 ports: - "[Replace this with private_ip or nothing]:5000:5000" environment: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data volumes: - ./data:/data
Configure
-
Configure Jenkins
- Setup Pipelines
- Go to
/homelocation and clone the<project>-devopspipelines. For example, go to/homeand clonehttps://github.com/Unified-Learner-Passbook/ULP-devops - Create symbolic links to Jenkins jobs
ln -s /home/ulp-devops/jobs/ULP /var/lib/jenkins/jobs/ - Set permissions
chown -R jenkins:jenkins jobs && chown -R jenkins:jenkins /var/lib/jenkins - Restart Jenkins -
systemctl restart jenkins. You should be able to see all the Jobs on the Jenkins Dashboard.
- Go to
- Setup environment variables in Jenkins
- Go to Dashboard -> Manage Jenkins -> Configure System
- Select environment variables checkbox and add
VAULT_ADDR_DEVandVAULT_TOKEN_DEVwith corresponding values you got while setting up Hashicorp Vault - These variables are needed in the
deployjobs in the pipeline.
- Setup Pipelines
-
Configure Ansible
jenkinsuser should be able tosshon to the Docker Swarm and Database Servers- Switch to
jenkinsuser and runssh-keygen. Select all default options. - Copy public key from
~/.ssh/id_rsa.puband paste it under~/.ssh/authorized_keyson the Docker Swarm and Database Server
- Switch to
- Configure Ansible Hosts
- Go to
https://github.com/Unified-Learner-Passbook/ULP-devops/blob/master/ansible_workspace_dir/inventory/hosts - Uncomment the localhost lines or add
localhostunderdevgroup. You can read more about ansible hosts here
- Go to