├── Ansible └── Ansible_installation.MD ├── Docker ├── DockerHub.MD ├── Docker_Commands.MD ├── Docker_Installation_Steps.MD └── install_apache_dockerfile.txt ├── Jenkins ├── Ansible_integration.MD ├── Git_plugin_install.MD ├── Installation.MD ├── S3_Artifact_for_Jenkins.md ├── junit_plugin_setup.MD └── maven_install.MD ├── Kubernetes └── k8s-setup.md ├── Nexus └── Nexus_Installation.MD ├── Nginx └── nginx_installation.MD ├── README.md ├── SimpeDevOpsProjects ├── Project-01.MD ├── Project-02.MD ├── Project-3.MD ├── Project-4.MD └── images │ └── Project-4.png ├── SonarQube ├── SonarQube_Installation.MD └── Sonar_Integration_with_Jenkins.MD └── Tomcat └── tomcat_installation.MD /Ansible/Ansible_installation.MD: -------------------------------------------------------------------------------- 1 | # Ansible Installation 2 | 3 | Ansible is an open source automation platform. It is very, very simple to setup and yet powerful. Ansible can help you with configuration management, application deployment, task automation. 4 | 5 | ### Follow this in **[YouTube](https://www.youtube.com/watch?v=79xFyOc_eEY) 6 | 7 | ### Prerequisites 8 | 9 | 1. An AWS EC2 instance 10 | 11 | ### Installation steps: 12 | 13 | Add a EPEL (Extra Packages for Enterprise Linux)third party repository to get packages for Ansible 14 | ```sh 15 | rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 16 | ``` 17 | 18 | Install Ansible 19 | ```sh 20 | yum install ansible -y 21 | ``` 22 | 23 | Check Ansible version 24 | 25 | ```sh 26 | ansible --version 27 | ``` 28 | 29 | Create a new user for ansible administration & grant admin access to user (Master and Slave) 30 | ```sh 31 | useradd ansadmin 32 | passwd ansadmin 33 | # below command addes ansadmin to sudoers file. But strongly recommended to use "visudo" command if you are aware vi or nano editor. 34 | echo "ansadmin ALL=(ALL) ALL" >> /etc/sudoers 35 | ``` 36 | 37 | Using keybased authentication is advised. If you are still at learning stage use password based authentication (Master & Slave) 38 | ```sh 39 | # sed command replaces "PasswordAuthentication no to yes" without editing file 40 | sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config 41 | ``` 42 | Login as a ansadmin user on master and generate ssh key (Master) 43 | ```sh 44 | ssh-keygen 45 | ``` 46 | Copy keys onto all ansible client nodes (Master) 47 | ```sh 48 | ssh-copy-id 49 | ``` 50 | 51 | Update target servers information on /etc/ansible/hosts file (Master) 52 | ```sh 53 | echo "" > /etc/ansible/hosts 54 | ``` 55 | Run ansible command as ansadmin user it should be successful (Master) 56 | ```sh 57 | ansible all -m ping 58 | ``` 59 | -------------------------------------------------------------------------------- /Docker/DockerHub.MD: -------------------------------------------------------------------------------- 1 | ## What is Docker Hub Registry 2 | 3 | Docker Hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker Cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline. 4 | 5 | ##### Ref URL : https://docs.docker.com/docker-hub/ 6 | 7 | 1. Create a docker hub account in https://hub.docker.com/ 8 | 9 | 2. Pull a docker image 10 | 11 | ```sh 12 | docker pull ubuntu 13 | ``` 14 | 15 | 3. pull a docker image with old version 16 | 17 | ```sh 18 | docker pull ubuntu:16.04 19 | ``` 20 | 21 | 4. create a custom tag to docker image 22 | ```sh 23 | docker tag ubuntu:latest valaxy/ubuntu:demo 24 | ``` 25 | 26 | 5. login to your docker hub registry 27 | ``sh 28 | docker login 29 | ``` 30 | 6. docker push valaxy/ubuntu:demo 31 | ``` 32 | 33 | ### testing 34 | 35 | 1. Remove all images in docker server 36 | ```sh 37 | docker image rm -f 38 | ``` 39 | 40 | 2. Pull your custom image from your docker account 41 | ```sh 42 | docker pull valaxy/ubuntu:demo 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /Docker/Docker_Commands.MD: -------------------------------------------------------------------------------- 1 | 2 | 1. how to search a docker image in hub.docker.com 3 | ```sh 4 | docker search httpd 5 | ``` 6 | 2. Download a docker image from hub.docker.com 7 | ```sh 8 | docker image pull : 9 | ``` 10 | 11 | 3. List out docker images from your local system 12 | ```sh 13 | docker image ls 14 | ``` 15 | 16 | 4. Create/run/start a docker container from image 17 | ```sh 18 | docker run -d --name : 19 | 20 | d - run your container in back ground (detached) 21 | ``` 22 | 23 | 5. Expose your application to host server 24 | ```sh 25 | docker run -d -p : --name : 26 | 27 | docker run -d --name httpd_server -p 8080:80 httpd:2.2 28 | ``` 29 | 30 | 6. List out running containers 31 | ```sh 32 | docker ps 33 | ``` 34 | 35 | 7. List out all docker container (running, stpooed, terminated, etc...) 36 | ```sh 37 | docker ps -a 38 | ``` 39 | 40 | 8. run a OS based container which interactive mode (nothing but login to container after it is up and running) 41 | 42 | ```sh 43 | docker run -i -t --name centos_server centos:latest 44 | i - interactive 45 | t - Terminal 46 | ``` 47 | 48 | 9. Stop a container 49 | ```sh 50 | docker stop 51 | ``` 52 | 53 | 10. Start a container which is in stopped or exit state 54 | 55 | ```sh 56 | docker start 57 | ``` 58 | 11. Remove a container 59 | 60 | ```sh 61 | docker rm 62 | ``` 63 | 64 | 12. login to a docker container 65 | ```sh 66 | docker exec -it /bin/bash 67 | ``` 68 | -------------------------------------------------------------------------------- /Docker/Docker_Installation_Steps.MD: -------------------------------------------------------------------------------- 1 | # Installing Docker on Amazon Linux server 2 | 3 | 1.Update packages 4 | ```sh 5 | yum update -y 6 | ``` 7 | 2.Install docker 8 | ```sh 9 | yum install docker -y 10 | ``` 11 | 12 | # Docker Installation on CentOS server 13 | ##### Referance URL : https://docs.docker.com/install/linux/docker-ce/centos/#install-using-the-repository 14 | ### PREREQUISITES 15 | 16 | Please follow below steps to install docker CE on CentoOS server instance. For RedHat only Docker EE available 17 | 18 | 1.Install required packages. 19 | 20 | ```sh 21 | sudo yum install -y yum-utils \ 22 | device-mapper-persistent-data \ 23 | lvm2 24 | 25 | ``` 26 | 27 | 2.Use the following command to set up the stable repository. 28 | 29 | ```sh 30 | sudo yum-config-manager \ 31 | --add-repo \ 32 | https://download.docker.com/linux/centos/docker-ce.repo 33 | ``` 34 | 35 | ### INSTALLING DOCKER CE 36 | 37 | 1.Install the latest version of Docker CE. 38 | ```sh 39 | sudo yum install docker-ce 40 | ``` 41 | 42 | If prompted to accept the GPG key, verify that the fingerprint matches 43 | 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it. 44 | 45 | 2.Start Docker. 46 | ```sh 47 | sudo systemctl start docker 48 | ``` 49 | 50 | 3.Verify that docker is installed correctly by running the hello-world image. 51 | ```sh 52 | sudo docker run hello-world 53 | ``` 54 | -------------------------------------------------------------------------------- /Docker/install_apache_dockerfile.txt: -------------------------------------------------------------------------------- 1 | FROM ubuntu:12.04 2 | 3 | MAINTAINER Valaxy Technologies valaxytech@gmail.com 4 | 5 | LABEL version="1.1.0" \ 6 | app_name="Training registration application" \ 7 | release_date="9-Sep-2018" 8 | RUN apt-get update && apt-get install -y apache2 && apt-get clean 9 | 10 | ENV APACHE_RUN_USER www-data 11 | ENV APACHE_RUN_GROUP www-data 12 | ENV APACHE_LOG_DIR /var/log/apache2 13 | 14 | EXPOSE 80 15 | 16 | COPY index.html /var/www/html 17 | CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"] 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Jenkins/Ansible_integration.MD: -------------------------------------------------------------------------------- 1 | # Ansible integration with Jenkins 2 | 3 | Follow this on **[YouTube](https://www.youtube.com/watch?v=nE4b9mW2ym0)** 4 | 5 | ### Prerequisites: 6 | 1. Ansible server **[Get Help Here](https://www.youtube.com/watch?v=79xFyOc_eEY)** 7 | 2. Jenkins Server **[Get Help Here](https://www.youtube.com/watch?v=M32O4Yv0ANc)** 8 | 9 | ### Part-01 Integration Setps 10 | 11 | Install "publish Over SSH" 12 | - `Manage Jenkins` > `Manage Plugins` > `Available` > `Publish over SSH` 13 | 14 | Enable connection between Ansible and Jenkins 15 | - `Manage Jenkins` > `Configure System` > `Publish Over SSH` > `SSH Servers` 16 | 17 | - SSH Servers: 18 | - Hostname:`` 19 | - username: `ansadm` 20 | - password: `*******` 21 | 22 | Test the connection "Test Connection" 23 | -------------------------------------------------------------------------------- /Jenkins/Git_plugin_install.MD: -------------------------------------------------------------------------------- 1 | # Configure Git pulgin on Jenkins 2 | Git is one of the most popular tool for version contorl system. you can pull code from git repositories using jenkins if you use github plugin. 3 | 4 | #### Follow this artical in **[YouTube](https://www.youtube.com/watch?v=wgfsVmHnAiM)** 5 | 6 | #### Prerequisites 7 | 1. Jenkins server **[Get Help Here](https://www.youtube.com/watch?v=M32O4Yv0ANc) 8 | 9 | #### Install Git on Jenkins server 10 | Install git packages on jenkins server 11 | ```sh 12 | yum install git -y 13 | ``` 14 | 15 | #### Setup Git on jenkins console 16 | - Install git plugin without restart 17 | - `Manage Jenkins` > `Jenkins Plugins` > `available` > `github` 18 | 19 | - Configure git path 20 | - `Manage Jenkins` > `Global Tool Configuration` > `git` 21 | 22 | #### Next Steps 23 | 24 | - [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) 25 | - [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) 26 | - [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) 27 | - [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) 28 | -------------------------------------------------------------------------------- /Jenkins/Installation.MD: -------------------------------------------------------------------------------- 1 | # Install Jenkins on AWS EC2 2 | Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project. 3 | 4 | ### Follow this article in **[Youtube](https://youtu.be/M32O4Yv0ANc)** 5 | 6 | ### Prerequisites 7 | 1. EC2 RHEL 7.x Instance [Get help here](https://www.youtube.com/watch?v=KDtS6BzJo3A) 8 | - With Internet Access 9 | - Security Group with Port `8080` open for internet 10 | 1. Java v1.8.x 11 | 12 | ## Install Java 13 | We will be using open java for our demo, Get latest version from http://openjdk.java.net/install/ 14 | ```sh 15 | yum install java-1.8* 16 | #yum -y install java-1.8.0-openjdk 17 | ``` 18 | 19 | ### Confirm Java Version 20 | Lets install java and set the java home 21 | ```sh 22 | java -version 23 | find /usr/lib/jvm/java-1.8* | head -n 3 24 | #JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64 25 | export JAVA_HOME 26 | PATH=$PATH:$JAVA_HOME 27 | # To set it permanently update your .bash_profile 28 | source ~/.bash_profile 29 | ``` 30 | _The output should be something like this,_ 31 | ``` 32 | [root@~]# java -version 33 | openjdk version "1.8.0_151" 34 | OpenJDK Runtime Environment (build 1.8.0_151-b12) 35 | OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode) 36 | ``` 37 | 38 | ## Install Jenkins 39 | You can install jenkins using the rpm or by setting up the repo. We will setup the repo so that we can update it easily in future. 40 | Get latest version of jenkins from https://pkg.jenkins.io/redhat-stable/ 41 | ```sh 42 | yum -y install wget 43 | wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo 44 | rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key 45 | yum -y install jenkins 46 | ``` 47 | 48 | ### Start Jenkins 49 | ```sh 50 | # Start jenkins service 51 | systemctl start jenkins 52 | 53 | # Setup Jenkins to start at boot, 54 | systemctl enable jenkins 55 | ``` 56 | 57 | #### Accessing Jenkins 58 | By default jenkins runs at port `8080`, You can access jenkins at 59 | ```sh 60 | http://YOUR-SERVER-PUBLIC-IP:8080 61 | ``` 62 | #### Configure Jenkins 63 | - The default Username is `admin` 64 | - Grab the default password 65 | - Password Location:`/var/lib/jenkins/secrets/initialAdminPassword` 66 | - `Skip` Plugin Installation; _We can do it later_ 67 | - Change admin password 68 | - `Admin` > `Configure` > `Password` 69 | - Configure `java` path 70 | - `Manage Jenkins` > `Global Tool Configuration` > `JDK` 71 | - Create another admin user id 72 | 73 | ### Test Jenkins Jobs 74 | 1. Create “new item” 75 | 1. Enter an item name – `My-First-Project` 76 | - Chose `Freestyle` project 77 | 1. Under Build section 78 | Execute shell : echo "Welcome to Jenkins Demo" 79 | 1. Save your job 80 | 1. Build job 81 | 1. Check "console output" 82 | 83 | ### Next Step 84 | - [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) 85 | - [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) 86 | - [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) 87 | - [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) 88 | - [ ] Setup Jenkins to run inside Tomcat Server 89 | -------------------------------------------------------------------------------- /Jenkins/S3_Artifact_for_Jenkins.md: -------------------------------------------------------------------------------- 1 | 2 | # S3 as a artifact for Jenkins 3 | 4 | Follow this in **[YouTube](https://youtu.be/GQZYpIRxi-g)** 5 | 6 | ### Prerequisites 7 | 1. Create Jenkins Server 8 | Jenkins server **[Get Help here](https://www.youtube.com/watch?v=M32O4Yv0ANc)** 9 | 10 | ### Setup steps 11 | 1. Create a S3 bucket to store artifacts 12 | `S3 --> Create bucket ` 13 | ```sh 14 | Bucket name: valaxy-s3-artifact 15 | Region: Singapore 16 | ``` 17 | 1. Create new IAM role with "S3 full access" and assign it to jenkins server 18 | `IAM --> Create role --> EC2` 19 | ```ssh 20 | Permission: AmazonS3FullAccess 21 | Tags: key - Name, Value - S3FullAccess Role 22 | name: S3_Full_Access 23 | ``` 24 | 25 | 1. Install "S3 Publisher" plugin on Jenkins 26 | `Manage Jenkins --> Manage Plugins --> Availabe --> S3 publisher` 27 | 28 | 1. Configure S3 profile on Jenkins 29 | `Manage Jenkins --> Configure Systems --> Amazon S3 profiles` 30 | ```sh 31 | Profile name : s3-artifact-repository 32 | Use IAM Role : chose 33 | ``` 34 | 35 | 1. Create a job to store artifacts under S3. 36 | -------------------------------------------------------------------------------- /Jenkins/junit_plugin_setup.MD: -------------------------------------------------------------------------------- 1 | # Configure Junit pulgin on Jenkins 2 | Junit is one of the most popular unit testing tool for java. install plugin to start with this 3 | 4 | #### Follow this artical in **[YouTube]()** 5 | 6 | #### Prerequisites 7 | 1. Jenkins server **[Get Help Here](https://www.youtube.com/watch?v=M32O4Yv0ANc) 8 | 9 | #### Setup maven on jenkins console 10 | - Install maven plugin without restart 11 | - `Manage Jenkins` > `Jenkins Plugins` > `available` > `junit` 12 | 13 | #### Next Steps 14 | 15 | - [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) 16 | - [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) 17 | - [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) 18 | - [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) 19 | -------------------------------------------------------------------------------- /Jenkins/maven_install.MD: -------------------------------------------------------------------------------- 1 | # Install & configure Maven build tool on Jenkins 2 | Maven is a code build tool which used to convert your code to artifact. this is widely used plugin to build in continuous integration 3 | 4 | #### Follow this artical in **[YouTube](https://www.youtube.com/watch?v=wgfsVmHnAiM)** 5 | 6 | #### Prerequisites 7 | 1. Jenkins server **[Get Help Here](https://www.youtube.com/watch?v=M32O4Yv0ANc) 8 | 9 | #### Install Maven on Jenkins 10 | Download maven packages https://maven.apache.org/download.cgi onto Jenkins server. In this case I am using /opt/maven as my installation directory 11 | - Link : https://maven.apache.org/download.cgi 12 | ```sh 13 | # Creating maven directory under /opt 14 | mkdir /opt/maven 15 | cd /opt/maven 16 | # downloading maven version 3.6.0 17 | wget http://mirrors.fibergrid.in/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.zip 18 | unzip /opt/maven/apache-maven-3.6.0-bin.zip 19 | ``` 20 | 21 | Setup M2_HOME and M2 paths in .bash_profile of user and add these to path variable 22 | ```sh 23 | vi ~/.bash_profile 24 | M2_HOME=/opt/maven/apache-maven-3.6.0 25 | M2=$M2_HOME/bin 26 | PAHT=:$M2_HOME:$M2 27 | ``` 28 | #### Check point 29 | logoff and login to check maven version 30 | Check maven version 31 | ```sh 32 | mvn –version 33 | ``` 34 | So far you have completed installation of maven software to support maven plugin on jenkins console. Let's jump onto jenkins to complete remining steps. 35 | 36 | #### Setup maven on jenkins console 37 | - Install maven plugin without restart 38 | - `Manage Jenkins` > `Jenkins Plugins` > `available` > `Maven Invoker` 39 | 40 | - Configure java path 41 | - `Manage Jenkins` > `Global Tool Configuration` > `Maven` 42 | 43 | #### Next Steps 44 | 45 | - [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) 46 | - [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) 47 | - [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) 48 | - [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) 49 | -------------------------------------------------------------------------------- /Kubernetes/k8s-setup.md: -------------------------------------------------------------------------------- 1 | 2 | #### Setup Kubernetes (K8s) Cluster on AWS 3 | 4 | 5 | 1. Create Ubuntu EC2 instance 6 | 1. install AWSCLI 7 | ```sh 8 | curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip 9 | apt install unzip python 10 | unzip awscli-bundle.zip 11 | #sudo apt-get install unzip - if you dont have unzip in your system 12 | ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws 13 | ``` 14 | 15 | 1. Install kubectl 16 | ```sh 17 | curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl 18 | chmod +x ./kubectl 19 | sudo mv ./kubectl /usr/local/bin/kubectl 20 | ``` 21 | 1. Create an IAM user/role with Route53, EC2, IAM and S3 full access 22 | 1. Attach IAM role to ubuntu server 23 | 24 | #### Note: If you create IAM user with programmatic access then provide Access keys. 25 | ```sh 26 | aws configure 27 | ``` 28 | 1. Install kops on ubuntu instance: 29 | ```sh 30 | curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 31 | chmod +x kops-linux-amd64 32 | sudo mv kops-linux-amd64 /usr/local/bin/kops 33 | ``` 34 | 1. Create a Route53 private hosted zone (you can create Public hosted zone if you have a domain) 35 | 1. create an S3 bucket 36 | ```sh 37 | aws s3 mb s3://dev.k8s.valaxy.in 38 | ``` 39 | 1. Expose environment variable: 40 | ```sh 41 | export KOPS_STATE_STORE=s3://dev.k8s.valaxy.in 42 | ``` 43 | 1. Create sshkeys before creating cluster 44 | ```sh 45 | ssh-keygen 46 | ``` 47 | 1. Create kubernetes cluster definitions on S3 bucket 48 | ```sh 49 | kops create cluster --cloud=aws --zones=ap-southeast-1b --name=dev.k8s.valaxy.in --dns-zone=valaxy.in --dns private 50 | ``` 51 | 1. Create kubernetes cluser 52 | ```sh 53 | kops update cluster dev.k8s.valaxy.in --yes 54 | ``` 55 | 1. Validate your cluster 56 | ```sh 57 | kops validate cluster 58 | ``` 59 | 60 | 1. To list nodes 61 | ```sh 62 | kubectl get nodes 63 | ``` 64 | 65 | #### Deploying Nginx container on Kubernetes 66 | 1. Deploying Nginx Container 67 | ```sh 68 | kubectl run sample-nginx --image=nginx --replicas=2 --port=80 69 | kubectl get pods 70 | kubectl get deployments 71 | ``` 72 | 73 | 1. Expose the deployment as service. This will create an ELB in front of those 2 containers and allow us to publicly access them: 74 | ```sh 75 | kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer 76 | kubectl get services -o wide 77 | ``` 78 | 1. To delete cluster 79 | ```sh 80 | kops delete cluster dev.k8s.valaxy.in --yes 81 | ``` 82 | -------------------------------------------------------------------------------- /Nexus/Nexus_Installation.MD: -------------------------------------------------------------------------------- 1 | # Nexus Installation 2 | Nexus is one a artifact repository which helps to store your build outcomes. 3 | 4 | ### Follow this article in **[Youtube](https://www.youtube.com/watch?v=83AGz9huJGo) 5 | ### Prerequisites 6 | 7 | 1. EC2 instance with java 8 | 9 | ### Implementation steps 10 | 11 | Download and setup nexus stable version 12 | ```sh 13 | cd /opt 14 | wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.0.2-02-unix.tar.gz 15 | tar -zxvf nexus-3.0.2-02-unix.tar.gz 16 | mv /opt/nexus-3.0.2-02 /opt/nexus 17 | ``` 18 | 19 | As a good security practice, it is not advised to run nexus service as root. so create new user called nexus and grant sudo access to manage nexus services 20 | ```sh 21 | sudo adduser nexus 22 | # visudo \\ nexus ALL=(ALL) NOPASSWD: ALL 23 | sudo chown -R nexus:nexus /opt/nexus 24 | ``` 25 | 26 | Open /opt/nexus/bin/nexus.rc file, uncomment run_as_user parameter and set it as following. 27 | ```sh 28 | vi /opt/nexus/bin/nexus.rc 29 | run_as_user="nexus" (file shold have only this line) 30 | ``` 31 | 32 | Add nexus as a service at boot time 33 | ```sh 34 | sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus 35 | ``` 36 | Login as a nexus user and start service 37 | ```sh 38 | su - nexus 39 | service nexus start 40 | ``` 41 | 42 | Login nexus server from browser on port 8081 43 | 44 | http://:8081 45 | 46 | Use default credentials to login 47 | 48 | username : admin 49 | password : admin123 50 | 51 | 52 | ### Troubleshooting 53 | 54 | service is not starting? 55 | - make sure you are trying to start service with nexus user. 56 | - check java installation 57 | 58 | Unable to access nexus URL? 59 | - make sure port 8081 is opened in security group. 60 | 61 | ### Next Steps 62 | - [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) 63 | - [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) 64 | - [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) 65 | - [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) 66 | -------------------------------------------------------------------------------- /Nginx/nginx_installation.MD: -------------------------------------------------------------------------------- 1 | 1. update your system 2 | ```sh 3 | # yum update 4 | ``` 5 | 6 | 2. Download Nginx latest version. version we use here is : 7 | 8 | 2. download latest version of nginx from http://nginx.org/en/download.html website 9 | ```sh 10 | # cd /opt 11 | # wget http://nginx.org/download/nginx-1.15.4.tar.gz 12 | # tar -zxvf nginx-1.15.4.tar.gz 13 | # mv nginx-1.15.4 /opt/nginx 14 | ``` 15 | 16 | 3. In order to compile our source code we need to install dependences. 17 | ```sh 18 | # yum groupinstall "Development Tools" 19 | # yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel 20 | ``` 21 | 22 | 4. Run /opt/nginx/configure file with below parameters 23 | ```sh 24 | # cd /opt/nginx 25 | # ./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid --with-http_ssl_module 26 | ``` 27 | 28 | 5. Now compile and install nginx 29 | ```sh 30 | # make 31 | # make install 32 | ``` 33 | 34 | 6. Check nginx version and start service to use. 35 | ```sh 36 | # nginx -V 37 | # nginx 38 | ``` 39 | 40 | 6. Setup nginx as a system servicecreate a file /lib/systemd/system/nginx.service and copy below URL content into that and modify according to your file path locations. 41 | ```sh 42 | 43 | Ref URL : https://www.nginx.com/resources/wiki/start/topics/examples/systemd/ 44 | 45 | # vi /lib/systemd/system/nginx.service 46 | ``` 47 | 48 | copy below contant in to nginx.service file by changing PIDFile location 49 | 50 | ```sh 51 | [Unit] 52 | Description=The NGINX HTTP and reverse proxy server 53 | After=syslog.target network.target remote-fs.target nss-lookup.target 54 | 55 | [Service] 56 | Type=forking 57 | PIDFile=/var/run/nginx.pid 58 | ExecStartPre=/usr/bin/nginx -t 59 | ExecStart=/usr/bin/nginx 60 | ExecReload=/usr/sbin/nginx -s reload 61 | ExecStop=/bin/kill -s QUIT $MAINPID 62 | PrivateTmp=true 63 | 64 | [Install] 65 | WantedBy=multi-user.target 66 | ``` 67 | 7. Start nginx and test 68 | ```sh 69 | # systemctl start nginx 70 | # systemctl enable nginx 71 | # ps aux | grep nginx 72 | ``` 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DevOpsDemos -------------------------------------------------------------------------------- /SimpeDevOpsProjects/Project-01.MD: -------------------------------------------------------------------------------- 1 | # Simple DevOps Project -01 2 | 3 | We know how to use work with each and Git, Jenkins independently. What if you want to collaborate these two? that is where Simple DevOps project helps you. Follow below steps if you are a new guy to DevOps. You love it. 4 | 5 | ### Follow this article in **[YouTube](https://www.youtube.com/watch?v=Z9G5stlXoyg)** 6 | #### Prerequisites 7 | 1. EC2 instance with tomcat installation **[installation steps video](https://youtu.be/m21nFreFw8A) 8 | 1. Jenkins server **[Get Help here](https://www.youtube.com/watch?v=M32O4Yv0ANc) 9 | 10 | ### Part-01 : Adding steps for Integration 11 | ### Steps to create Jenkin job 12 | 1. Login to Jenkins console 13 | 1. Create *Jenkins job*, Fill the following details, 14 | - *Source Code Management:* 15 | - Repository: `https://github.com/ValaxyTech/hello-world.git` 16 | - Branches to build : `*/master` 17 | - *Build:* 18 | - Root POM:`pom.xml` 19 | - Goals and options : `clean install package` 20 | 21 | ### Part-02: Adding Deployment Steps 22 | in this port we are going to install 'deploy to container' plugin. this is need to deploy on tomcat server which we are using. 23 | 24 | - Install maven plugin without restart 25 | - `Manage Jenkins` > `Jenkins Plugins` > `available` > `deploy to container` 26 | 27 | To deploy our build artifacts on tomcat server our Jenkins server need access. For this we should setup credentials. This option is available in Jenkins home page 28 | 29 | - setup credentials 30 | - `credentials` > `jenkins` > `Global credentials` > `add credentials` 31 | - Username : `deployer` 32 | - Password : `XXXXXXX` 33 | - id : `Tomcat_user` 34 | - Description: `Tomcat user to deploy on tomcat server` 35 | 36 | Modify the same job which created in part-01 and add deployment steps. 37 | - Post Steps 38 | - Deploy war/ear to container 39 | - WAR/EAR files : `**/*.war` 40 | - Containers : `Tomcat 8.x` 41 | - Credentials: `Tomcat_user` (which created in above step) 42 | - Tomcat URL : `http://:` 43 | 44 | Save and run the job now. 45 | 46 | ### Port-03 : Continuous Integration & Continuous Deployment (CI/CD) 47 | Now job is running fine but to make this as Continuous Integration and Continuous Deployment Tod do that go back and modify job as below. 48 | - Build Triggers 49 | - Poll SCM 50 | - schedule `*/2 * * * *` 51 | 52 | Save the job and modify the code in GitHub. Then you could see your job get trigger a build without any manual intervention. 53 | -------------------------------------------------------------------------------- /SimpeDevOpsProjects/Project-02.MD: -------------------------------------------------------------------------------- 1 | # Simple DevOps Project -02 2 | 3 | Follow this on **[YouTube](https://www.youtube.com/watch?v=nE4b9mW2ym0)** 4 | 5 | ### Prerequisites: 6 | 1. Ansible server **[Get Help Here](https://www.youtube.com/watch?v=79xFyOc_eEY)** 7 | 2. Jenkins Server **[Get Help Here](https://www.youtube.com/watch?v=M32O4Yv0ANc)** 8 | 3. Tocmat Server **[Get Help Here](https://www.youtube.com/watch?v=m21nFreFw8A)** 9 | 10 | ### Part-01 Integration Setps 11 | 12 | Install "publish Over SSH" 13 | - `Manage Jenkins` > `Manage Plugins` > `Available` > `Publish over SSH` 14 | 15 | Enable connection between Ansible and Jenkins 16 | 17 | - `Manage Jenkins` > `Configure System` > `Publish Over SSH` > `SSH Servers` 18 | 19 | - SSH Servers: 20 | - Hostname:`` 21 | - username: `ansadm` 22 | - password: `*******` 23 | 24 | Test the connection "Test Connection" 25 | 26 | ### Part-02 - Execute job to connect 27 | 28 | create a copywarfile.yml on Ansible under /opt/playbooks 29 | 30 | ```sh 31 | # copywarfile.yml 32 | --- 33 | - hosts: all 34 | become: true 35 | tasks: 36 | - name: copy jar/war onto tomcat servers 37 | copy: 38 | src: /op/playbooks/wabapp/target/webapp.war 39 | dest: /opt/apache-tomcat-8.5.32/webapps 40 | ``` 41 | Add tomcat server details to /etc/ansible/hosts (if you are using other hosts file update server info there) 42 | ```sh 43 | echo "" >> /etc/ansible/hosts 44 | ``` 45 | Create *Jenkins job*, Fill the following details, 46 | 47 | - *Source Code Management:* 48 | - Repository: `https://github.com/ValaxyTech/hello-world.git` 49 | - Branches to build : `*/master` 50 | - *Build:* 51 | - Root POM:`pom.xml` 52 | - Goals and options : `clean install package` 53 | 54 | - *Add post-build steps* 55 | - Send files or execute commands over SSH 56 | - SSH Server : `ansible_server` 57 | - Source fiels: `webapp/target/*.war` 58 | - Remote directory: `//opt//playbooks` 59 | - *Add post-build steps* 60 | - Send files or execute commands over ssH 61 | - SSH Server : `ansible_server` 62 | - Exec command ansible-playbook /opt/playbooks/copywarfile.yml 63 | 64 | Execute job and you should be able to seen build has been deployed on Tomcat server. 65 | 66 | 67 | -------------------------------------------------------------------------------- /SimpeDevOpsProjects/Project-3.MD: -------------------------------------------------------------------------------- 1 | ## Simple DevOps Project -3 2 | 3 | 4 | 1. Launch an EC2 instance for Docker host 5 | 6 | 2. Install docker on EC2 instance and start services 7 | ```sh 8 | yum install docker 9 | service docker start 10 | ``` 11 | 12 | 3. create a new user for Docker management and add him to Docker (default) group 13 | ```sh 14 | useradd dockeradmin 15 | passwd dockeradmin 16 | usermod -aG docker dockeradmin 17 | ``` 18 | 19 | 4. Write a Docker file under /opt/docker 20 | 21 | ```sh 22 | mkdir /opt/docker 23 | 24 | ### vi Dockerfile 25 | # Pull base image 26 | From tomcat:8-jre8 27 | 28 | # Maintainer 29 | MAINTAINER "valaxytech" 30 | 31 | # copy war file on to container 32 | COPY ./webapp.war /usr/local/tomcat/webapps 33 | ``` 34 | 35 | 5. Login to Jenkins console and add Docker server to execute commands from Jenkins 36 | Manage Jenkins --> Configure system --> Publish over SSH --> add Docker server and credentials 37 | 38 | 6. Create Jenkins job 39 | 40 | A) Source Code Management 41 | Repository : https://github.com/ValaxyTech/hello-world.git 42 | Branches to build : */master 43 | 44 | B) Build 45 | Root POM: pom.xml 46 | Goals and options : clean install package 47 | 48 | C) send files or execute commands over SSH 49 | Name: docker_host 50 | Source files : `webapp/target/*.war` 51 | Remove prefix : `webapp/target` 52 | Remote directory : `//opt//docker` 53 | Exec command[s] : 54 | ```sh 55 | docker stop valaxy_demo; 56 | docker rm -f valaxy_demo; 57 | docker image rm -f valaxy_demo; 58 | cd /opt/docker; 59 | docker build -t valaxy_demo . 60 | ``` 61 | 62 | D) send files or execute commands over SSH 63 | Name: `docker_host` 64 | Exec command : `docker run -d --name valaxy_demo -p 8090:8080 valaxy_demo` 65 | 66 | 7. Login to Docker host and check images and containers. (no images and containers) 67 | 68 | 8. Execute Jenkins job 69 | 70 | 9. check images and containers again on Docker host. This time an image and container get creates through Jenkins job 71 | 72 | 10. Access web application from browser which is running on container 73 | ``` 74 | :8090 75 | ``` 76 | -------------------------------------------------------------------------------- /SimpeDevOpsProjects/Project-4.MD: -------------------------------------------------------------------------------- 1 | # Simple DevOps Project - 4 2 | 3 | 4 | 5 | In this project, we will be see how to *use Git, Jenkins, Ansible, DockerHub, Docker to DEPLOY on a docker container.,* 6 | 7 | *Follow this project in *[Youtube](https://youtu.be/MJ74RcL6jv8)** 8 | 9 | ![](https://github.com/ValaxyTech/DevOpsDemos/blob/master/SimpeDevOpsProjects/images/Project-4.png) 10 | 11 | #### PreRequisites 12 | 1. Jenkins - Get help [here](https://www.youtube.com/watch?v=M32O4Yv0ANc) 13 | 1. Ansible - Get help [here](https://www.youtube.com/watch?v=79xFyOc_eEY) 14 | 1. Setup ansible client and install docker. [here](https://www.youtube.com/watch?v=nMLQgXf8tZ0) 15 | 1. Docker Hub account 16 | 17 | #### Previous DevOps projects: 18 | 19 | 1. Simple DevOps project-1 [here](https://www.youtube.com/watch?v=Z9G5stlXoyg) 20 | 1. Simple DevOps project-2 [here](https://www.youtube.com/watch?v=nE4b9mW2ym0) 21 | 1. Simple DevOps project-3 [here](https://www.youtube.com/watch?v=nMLQgXf8tZ0) 22 | 23 | In *part-01* we create Docker image on ansible server through Jenkins job and pushed it onto DockerHub. 24 | 25 | ### Part-01 : Create an docker image 26 | 27 | 1. Login to Jenkins console 28 | 1. Create *Jenkins job*, Fill the following details, 29 | - *Source Code Management:* 30 | - Repository : `https://github.com/ValaxyTech/hello-world.git` 31 | - Branches to build : `*/master` 32 | - *Build:* 33 | - Root POM:`pom.xml` 34 | - Goals and options : `clean install package` 35 | - *Post Steps* 36 | - *Send files or execute commands over SSH* 37 | - Name: `ansible_server` 38 | - Source files : `webapp/target/*.war` 39 | - Remove prefix : `webapp/target` 40 | - Remote directory : `//opt//docker` 41 | 42 | - *Send files or execute commands over SSH* 43 | - Name: `ansible_server` 44 | - Source files : `Dockerfile` 45 | - Remote directory : `//opt//docker` 46 | - Exec Command: 47 | - `cd /opt/docker` 48 | - `docker build -t valaxy_demo .` 49 | - `docker tag valaxy_demo valaxy/valaxy_demo` 50 | - `docker push valaxy/valaxy_demo` 51 | - `docker rmi valaxy_demo valaxy/valaxy_demo` 52 | 53 | 1. Login to Docker host and check images and containers. (no images and containers) 54 | 55 | 1. login to docker hub and check. shouldn't find images with for valaxy_demo 56 | 57 | 1. Execute Jenkins job 58 | 59 | 1. check images in Docker hub. Now you could able to see new images pushed to Valaxy Docker_Hub 60 | 61 | #### Troubleshooting: 62 | 1. Docker should be installed on ansible server 63 | 1. Should login to "docker hub" on ansible server 64 | 1. ansadmin user should be part of `docker` group 65 | 66 | In *Part-02* we create *create_docker_container.yml* playbook. this get intiated by jenkins job, run by ansible and exected on dokcer_host 67 | 68 | ### Part-02 : Deploy Containers 69 | 70 | 1. Write a yml file to create a container (file name : create_docker_container.yml) 71 | ```yaml 72 | --- 73 | - hosts: web-servers 74 | become: true 75 | tasks: 76 | - name: stop previous version docker 77 | shell: docker stop valaxy_demo 78 | - name: remove stopped container 79 | shell: docker rm -f valaxy_demo 80 | - name: remove docker images 81 | shell: docker image rm -f valaxy/valaxy_demo 82 | 83 | - name: create docker image 84 | shell: docker run -d --name valaxy_demo -p 8090:8080 valaxy/valaxy_demo 85 | 86 | 1. Add this script to Jenkins job. 87 | - Chose *"configure"* to modify your jenkins job. 88 | - *Under post build actions* 89 | - Send files or execute commands over SSH 90 | - Exec Command: 91 | ```sh 92 | cd /opt/playbooks 93 | ansible-playbook create_docker_container.yml 94 | ``` 95 | 96 | 1. Execute Jenkins job. 97 | 98 | 1. You could see a new container on your docker host. can able access it from browser on port 8090 99 | 100 | Troubleshooting: 101 | Makesure you have opened required ports on AWS Security group for this server. 102 | 103 | In *Part-03* we try to improvise to store docker images previous versions 104 | 105 | ### Part-03 : Deploy with Version Control Containers 106 | 107 | So for we used latest docker image to build a container, but what happens if latest version is not working? 108 | One easiest solution is, maintaining version for each build. This can be achieved by using environment variables. 109 | 110 | here we use 2 variables 111 | - `BUILD_ID` - The current build id 112 | - `JOB_NAME` - Name of the project of this build. This is the name you gave your job when you first set it up. 113 | 114 | for more info Please refer [this URL](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) 115 | 116 | Lets modify jenkins job which was created in *Part-01* as below. 117 | 118 | 1. Create Jenkins job 119 | - *Source Code Management:* 120 | - Repository : `https://github.com/ValaxyTech/hello-world.git` 121 | - Branches to build : `*/master` 122 | - *Build:* 123 | - Root POM:`pom.xml` 124 | - Goals and options : `clean install package` 125 | 126 | - *Send files or execute commands over SSH* 127 | - Name: `ansible_server` 128 | - Source files : `webapp/target/*.war` 129 | - Remove prefix : `webapp/target` 130 | - Remote directory : `//opt//docker` 131 | 132 | - *Send files or execute commands over SSH* 133 | - Name: `ansible_server` 134 | - Source files : `Dockerfile` 135 | - Remote directory : `//opt//docker` 136 | - `cd /opt/docker` 137 | - `docker build -t $JOB_NAME:v1.$BUILD_ID .` 138 | - `docker tag $JOB_NAME:v1.$BUILD_ID valaxy/$JOB_NAME:v1.$BUILD_ID` 139 | - `docker tag $JOB_NAME:v1.$BUILD_ID valaxy/$JOB_NAME:latest` 140 | - `docker push valaxy/$JOB_NAME:v1.$BUILD_ID` 141 | - `docker push valaxy/$JOB_NAME:latest` 142 | - `docker rmi $JOB_NAME:v1.$BUILD_ID valaxy/$JOB_NAME:v1.$BUILD_ID` 143 | - `valaxy/$JOB_NAME:latest` 144 | ##### References 145 | [1] - [Jenkins Docs - Building Software Projects](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) 146 | -------------------------------------------------------------------------------- /SimpeDevOpsProjects/images/Project-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/athmakuru/ValaxyTech-DevOpsDemos/328647fba6a18d1f43422423095d6d3383639064/SimpeDevOpsProjects/images/Project-4.png -------------------------------------------------------------------------------- /SonarQube/SonarQube_Installation.MD: -------------------------------------------------------------------------------- 1 | # SonarQube Installation 2 | 3 | SonarQube provides the capability to not only show health of an application but also to highlight issues newly introduced. With a Quality Gate in place, you can fix the leak and therefore improve code quality systematically. 4 | ### Follow this Article in **[YouTube](https://www.youtube.com/watch?v=zRQrcAi9UdU)** 5 | 6 | ### Prerequisites 7 | 1. EC2 instance with Java installed 8 | 1. MySQL Database Server or MyQL RDS instance. **[Get help here](https://www.youtube.com/watch?v=vLaW6b441x0)** 9 | 10 | ### Installation 11 | 12 | Install MySQL client version 13 | 14 | ```sh 15 | # yum install mysql 16 | ``` 17 | Download stable SonarQube version from below website. 18 | - Website: https://www.sonarqube.org/downloads/ 19 | - Note: This Article written for SonarQube6.0 20 | 21 | Download & unzip SonarQube 6.0 22 | ```sh 23 | # cd /opt 24 | # wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.0.zip 25 | # unzip sonarqube-6.0.zip 26 | # mv /opt/sonarqube-6.0 /opt/sonar 27 | ``` 28 | Allow RDS instance security group to access SonarQube server 29 | 30 | Connect to RDS instance with database credentials 31 | ```sh 32 | mysql -h :3306 -u -p 33 | ``` 34 | Create a new sonar database 35 | ```sh 36 | CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 37 | ``` 38 | 39 | Create a local and a remote user 40 | ```sh 41 | CREATE USER sonar@localhost IDENTIFIED BY 'sonar'; 42 | CREATE USER sonar@'%' IDENTIFIED BY 'sonar'; 43 | ``` 44 | 45 | Grant database access permissions to users 46 | ```sh 47 | GRANT ALL ON sonar.* TO sonar@localhost; 48 | GRANT ALL ON sonar.* TO sonar@'%'; 49 | ``` 50 | 51 | check users and databases 52 | ```sh 53 | use mysql 54 | show databases; 55 | SELECT User FROM mysql.user; 56 | FLUSH PRIVILEGES; 57 | QUIT 58 | ``` 59 | So for you have configured required database information on RDS. Let’s Jump back to your EC2 instance and enable SonarQube properties file to connect his Database. 60 | 61 | ### ON EC2 Instance 62 | Edit sonar properties file to uncomment and provide required information for below properties. 63 | 64 | - File Name: /opt/sonar/conf/sonar.properties 65 | - sonar.jdbc.username=`sonar` 66 | - sonar.jdbc.password=`sonar` 67 | - sonar.jdbc.url=jdbc:mysql://`:3306`/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false 68 | - sonar.web.host=`0.0.0.0` 69 | - sonar.web.context=`/sonar` 70 | 71 | Start SonarQube service 72 | ```sh 73 | # cd /opt/sonar/bin/linux-x86-64/ 74 | # ./sonar.sh start 75 | ``` 76 | 77 | ##### Run SonarQube as a default service 78 | 79 | Implement SonarQube server as a service 80 | ```sh 81 | Copy sonar.sh to etc/init.d/sonar and modify it according to your platform. 82 | # sudo cp /opt/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar 83 | # sudo vi /etc/init.d/sonar 84 | ``` 85 | 86 | Add below values to your /etc/init.d/sonar file 87 | ```sh 88 | Insert/modify below values 89 | SONAR_HOME=/opt/sonar 90 | PLATFORM=linux-x86-64 91 | 92 | WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper" 93 | WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf" 94 | PIDDIR="/var/run" 95 | ``` 96 | 97 | Start SonarQube server 98 | ```sh 99 | # service sonar start 100 | ``` 101 | SonarQube application uses port 9000. access SonarQube from browser 102 | ```sh 103 | http://:9000/sonar 104 | ``` 105 | ### Troubleshooting 106 | 107 | 1. Check whether you enabled port 9000 in EC2 instance security group 108 | 2. Check whether you enabled EC2 instance IP range in RDS security group 109 | 110 | ### Next Step 111 | - [x] [Integrate SonarQube with Jenkins](https://www.youtube.com/watch?v=k-3krTRuAFA) 112 | -------------------------------------------------------------------------------- /SonarQube/Sonar_Integration_with_Jenkins.MD: -------------------------------------------------------------------------------- 1 | 2 | ## SonarQube Integration with Jenkins 3 | 4 | Integration SonarQube server with Jenkins is necessary to store your reports. Follow below steps to enable that. 5 | ### Follow this in **[YouTube](https://www.youtube.com/watch?v=k-3krTRuAFA)** 6 | 7 | ### Prerequisites 8 | 1. SonarQube Server **[Get Help here](https://www.youtube.com/watch?v=zRQrcAi9UdU)** 9 | 1. Jenkins Server **[Get Help here](https://www.youtube.com/watch?v=M32O4Yv0ANc)** 10 | 11 | ### Implementation 12 | 13 | Login to Jenkins server and install sonarqube scanner. 14 | 15 | - SonarQube scanner URL : https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner 16 | - Package : https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip 17 | - 18 | ```sh 19 | # wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip 20 | # unzip sonar-scanner-cli-3.2.0.1227-linux.zip 21 | # mv sonar-scanner-3.2.0.1227-linux /opt/sonar_scanner 22 | ``` 23 | 24 | Set SonarQube server details in sonar-scanner property file 25 | 26 | - Sonar properties file: /opt/sonar_scanner/conf/sonar-scanner.properties 27 | - sonar.host.url=http://``:9000 28 | 29 | Login to Jenkins GUI console and install " SonarQube scanner" plugin 30 | 31 | - `Manage Jenkins` > `Manage Plugins` > `Avalable` > `SonarQube scanner` 32 | 33 | Configure SonarQube scanner home path 34 | 35 | - `Manage Jenkins` > `Global Tool Configuration` > `SonarQube Scanner` 36 | - Name : `sonar_scanner` 37 | - SONAR_RUNNER_HOME : `/opt/sonar_scanner` 38 | 39 | Configure SonarQube server name and authentication token 40 | - `Manage Jenkins` > `Configure Systems` > `SonarQube Servers` 41 | - Name : `SonarQube` 42 | - ServerURL : `http://:9000/sonar` 43 | - Server `authentication token` 44 | To Get Authentication code follow below steps. 45 | Login to SonarQube server as a admin `My Account` > `Security` > `Generate Token` 46 | 47 | Create a job to test SonarQube. Provide below sonar properties details in the job under build 48 | - Build: 49 | - `Execute SonarQube Scanner` > `Analysis properties` (it is mandatary). 50 | - sonar.projectKey=`Valaxy` 51 | - sonar.projectName=`ValaxyDemo` 52 | - sonar.projectVersion=`1.0` 53 | - sonar.sources=`/var/lib/jenkins/workspace/$JOB_NAME//src` 54 | 55 | Execute job to get analysis report. 56 | 57 | ### Next Step 58 | - [x] [Nexus Installation](https://www.youtube.com/watch?v=83AGz9huJGo) 59 | -------------------------------------------------------------------------------- /Tomcat/tomcat_installation.MD: -------------------------------------------------------------------------------- 1 | # Tomcat installation on EC2 instance 2 | 3 | ### Follow this article in **[YouTube](https://www.youtube.com/watch?v=m21nFreFw8A)** 4 | ### Prerequisites 5 | 1. EC2 instance with Java v1.8.x 6 | 7 | ### Install Apache Tomcat 8 | Download tomcat packages from https://tomcat.apache.org/download-80.cgi onto /opt on EC2 instance 9 | ```sh 10 | # create tomcat directory 11 | cd /opt 12 | wget http://mirrors.fibergrid.in/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz 13 | tar -xvzf /opt/apache-tomcat-8.5.35.tar.gz 14 | ``` 15 | give executing permissions to startup.sh and shutdown.sh which are under bin. 16 | ```sh 17 | chmod +x /opt/apache-tomcat-8.5.35/bin/startup.sh shutdown.sh 18 | ``` 19 | 20 | create link files for tomcat startup.sh and shutdown.sh 21 | ```sh 22 | ln -s /opt/apache-tomcat-8.5.35/bin/startup.sh /usr/local/bin/tomcatup 23 | ln -s /opt/apache-tomcat-8.5.35/bin/shutdown.sh /usr/local/bin/tomcatdown 24 | tomcatup 25 | ``` 26 | #### check point : 27 | access tomcat application from browser on prot 8080 28 | http://:8080 29 | 30 | Using unique ports for each application is a best practice in an environment. But tomcat and Jenkins runs on ports number 8080. Hence lets change tomcat port number to 8090. Change port number in conf/server.xml file under tomcat home 31 | ```sh 32 | cd /opt/apache-tomcat-8.5.35/conf 33 | # update port number in the "connecter port" field in server.xml 34 | # restart tomcat after configuration update 35 | tomcatdown 36 | tomcatup 37 | ``` 38 | #### check point : 39 | access tomcat application from browser on prot 8090 40 | http://:8090 41 | 42 | now application is accessible on port 8090. but tomcat application doesnt allow to login from browser. changing a default parameter in context.xml does address this issue 43 | ```sh 44 | #search for context.xml 45 | find / -name context.xml 46 | ``` 47 | above command gives 3 context.xml files. comment () `Value ClassName` field on files which are under webapp directory. 48 | After that restart tomcat services to effect these changes 49 | ```sh 50 | tomcatdown 51 | tomcatup 52 | ``` 53 | Update users information in the tomcat-users.xml file 54 | goto tomcat home directory and Add below users to conf/tomcat-user.xml file 55 | ```sh 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | ``` 64 | Restart serivce and try to login to tomcat application from the browser. This time it should be Successful 65 | 66 | --------------------------------------------------------------------------------