Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

git clone https://github.com/project-sunbird/sunbird-devops.git
cd sunbird-devops && git checkout tags/release-1.14.0 -b release-1.14.0
cd deploy/jenkins
sudo bash jenkins-server-setup.sh

...

12. Follow the onscreen instruction of the script. Provide choice as yes for all questions. The options are case sensitive, the script will display the accepted options.
13. Once the script completes copying the job config, go to the browser and restart jenkins using public-ip:8080/restart OR domain-name:8080/restart
14. Go to http://<jenkins_domain>/credentials/store/system/domain/_/newCredentials
15. Select Username with Password
16. Enter the username and password of the github account . This github account will require a private repository which will contain the inventory and other secrets. Currently github signup and github private repository is free for all.
17. Create an empty private repository
18. Also keep your dockerhub credentials handy. You will require it in subsequent steps. Currently dockerhub signup is free for all.
19. You can leave the ID blank so that jenkins auto generates it or you can give the ID to some long unique string such as abcde-fghij-klmno
20where the private repo will be hosted.
17. Enter a unique long string for the ID field such as private-repo-creds
18. You can provide the description as private repo credentails and click OK.
21. If you have left the ID blank, then click on the credential which was just created and then clikc on update. Jenkins will display the auto generated id. Copy this and keep it handy. We will require this in subsequent steps.
22. 19. Goto http://<jenkins_domain>/configure
2320. Choose the check box named “Environment variables”
2421. Click on Add and enter the following Name, Value pairs

Name

Value

ANSIBLE_FORCE_COLOR

true

ANSIBLE_HOST_KEY_CHECKING

false

ANSIBLE_STDOUT_CALLBACK

debug

hub_org

docker hub organization / username eg: In sunbird/player image, sunbird is the hub_org

private_repo_branch

The branch name in the private repository which you would like to use. This branch will have the inventory and secrets

private_repo_credentials

The autogenerated ID created by jenkins or unique string which you provided for ID field while entering the github repo credentials. eg: private-repo-creds

private_repo_url

The github URL to your private repo. You can visit your private repo and click on clone button, which will display the https URL to your private repository. Only https URL is currently supporrted.

public_repo_branch

This is the branch or tag from where Jenkinsfile will be picked up. You can set this value as refs/tags/release-1.14.0 if you want to build from tags or provide the value of development branch like release-1.15 . If you prefer building from tags, set this value for tags

...

(not recommened since development branches are not stable). 

22. Scroll down to “Global Pipeline Libraries” section and click Add. Provide the values as below

NameValue
Library Namedeploy-conf
Default versionTag name of the jenkins shared library. This should be same version of the release you are going to build and deploy. For example, if you decide to use tags release-1.14.0 as your base, jenkins shared library tag will be release-1.14.0-shared-lib. When you upgrade to tags release-1.15.0, this value should get changed to release-1.15.0-shared-lib
Retrieval methodModern SCM
Source Code ManagementGit
Project Repositoryhttps://github.com/project-sunbird/sunbird-devops.git

2523. Click on Save and go to Manage Jenkins -> Configure global security
2624. Choose the “Markup Formatter” as “Safe HTML”
2725. Go to Manage Jenkins -> Manager Nodes -> Click master -> Click Configure -> Provide labels as “build-slave
2826. Set the number of executors to a number like 15 if your system configuration is 16 GB RAM and 4 core CPU. Adjust this number accordingly based on your system configuration
2927. Restart jenkins by running sudo service jenkins restart
3028. Switch back to the terminal session on Jenkins server

sudo su jenkins
mkdir -p /var/lib/jenkins/secrets && cd /var/lib/jenkins/secrets
touch deployer_ssh_key ops_ssh_key vault-pass
chmod 400 deployer_ssh_key ops_ssh_key vault-pass

3129. The key which you used to login to the Jenkins server will be called as ops_ssh_key from now on wards. Example:

ssh -i somekey.pem ubuntu@jenkins-server-ip
Here somekey.pem is the key you used to login to the Jenkins server which will be called as ops_ssh_key

3230. Copy the contents of the key you used to connect to VM into ops_ssh_key file
3331. Create a new ssh key on your local machine or any server. We will use this for a user named deployer (or any name you like)
3432. ssh-keygen -f deployer_ssh_key (passphrase should be empty)
3533. Copy the contents of the deployer_ssh_key into /var/lib/jenkins/secrets/deployer_ssh_key
3634. If your github private repo consists of ansible encrypted files, then enter the decryption password in /var/lib/jenkins/secrets/vault-pass. If there are no encrypted files, then enter some random value like 12345 into the vault-pass file. This file cannot be empty.

37. Install git LFS. Run these commands

...

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

sudo apt-get install git-lfs

...

35. Restart Jenkins server

36. Follow the next set of steps to create inventory, secrets and ansible hosts in the private repo.