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_default
in 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
/home
location and clone the<project>-devops
pipelines. For example, go to/home
and 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_DEV
andVAULT_TOKEN_DEV
with corresponding values you got while setting up Hashicorp Vault - These variables are needed in the
deploy
jobs in the pipeline.
- Setup Pipelines
-
Configure Ansible
jenkins
user should be able tossh
on to the Docker Swarm and Database Servers- Switch to
jenkins
user and runssh-keygen
. Select all default options. - Copy public key from
~/.ssh/id_rsa.pub
and paste it under~/.ssh/authorized_keys
on 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
localhost
underdev
group. You can read more about ansible hosts here
- Go to