Devops

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Department of

Laboratory

Record

Name of the Student :

Register Number :

Department :

Semester :
BONAFIDE CERTIICATE
University Reg.No. This is to certify that this is a bonafide

record work done by Mr./Miss.

studying B.E/BTech., Department in

the Laboratory for Semester.

Staff-in-Charge Head of the Department

Submitted for the University Practical examination held on at

Velammal Institute of Technology

Internal Examiner External Examiner


CONTENTS

Ex. Date Title of the Experiment Page Sign


No. No.

1. 24-08-24 Create Maven Build pipeline in Azure.

2. 27-08-24 Run regression tests using Maven Build pipeline


in Azure.

3 3-09-24 Install Jenkins in Cloud.

4 10-09-24 Create CI pipeline using Jenkins.

5 24-09-24 Create a CD pipeline in Jenkins and deploy in


Cloud.

6 1-10-24 Create an Ansible playbook for a simple web


application infrastructure.

7 15-10-24 Build a simple application using Gradle.

8 29-10-24 Install Ansible and configure ansible roles and to


write playbooks.
Vision and Mission of the College

Vision of Institute
Velammal Institute of Technology is committed to be a leader in innovative work force development
and a world class learning venue for the ever-changing needs of business and Industry.

Mission of Institute
 To promote quality education & technical skills to meet the industry requirements.
 To incorporate Team work, Leadership skills & Lifelong learning.
 To facilitate Career development & Higher education assistance
 To encourage innovative ideas for Research & Development and Entrepreneurship for societal
needs.
 To inculcate Ethical responsibility & Human values

Department of Information Technology


Vision and Mission of Department of Information Technology

Vision of the Department


To be a center of excellence in the field of Information Technology to solve complex industrial and
societal needs.

Mission of the Department


 Imparting strong knowledge to students in recent technologies by organizing various technical
events.
 Providing platform for the students to encourage creativity, team work, leadership quality and
social responsibility
 Developing the employability and entrepreneurial skills of the students by conducting industry
collaborated training.
 Inculcating the importance of research and higher education through awareness programs.
Department of Information Technology
Programme Educational Objectives (PEOs) & Program Specific Outcomes
Programme Educational Objectives
PEO I:
Demonstrate technical competence with analytical and critical thinking to understand
and meet the diversified requirements of industry, academia and research.

PEO II:
Exhibit technical leadership, team skills and entrepreneurship skills to provide business solutions to
real world problems.

PEO III:
Work in multi-disciplinary industries with social and environmental responsibility work ethics and
adaptability to address complex engineering and social problems

PEO IV:
Pursue lifelong learning, use cutting edge technologies and involve in applied research to design
optimal solutions.

Program Specific Outcomes


PSO1:
Have proficiency in programming skills to design, develop and apply appropriate techniques, to
solve complex engineering problems

PSO2:
Have knowledge to build, automate and manage business solutions using cutting edge technologies.

PSO3:
Have excitement towards research in applied computer technologies.
Program Outcomes
Program Outcomes
Engineering knowledge: Apply the knowledge of mathematics, science, engineering
PO1 fundamentals, and an engineering specialization to the solution of complex engineering
problems.
Problem analysis: Identify, formulate, review research literature, and analyze complex
PO2 engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
PO3 consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
Conduct investigations of complex problems: Use research-based knowledge and research
PO4 methods including design of experiments, analysis and interpretation of data, and synthesis
of the information to provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
PO5 engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
The engineer and society: Apply reasoning informed by the contextual knowledge to assess
PO6 societal, health, safety, legal and cultural issues and the consequent responsibilities relevant
to the professional engineering practice.
Environment and sustainability: Understand the impact of the professional engineering
PO7 solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.
Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
PO8 norms of the engineering practice.
Individual and team work: Function effectively as an individual, and as a member or
PO9 leader in diverse teams, and in multidisciplinary settings.
Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
PO10 write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.
Project management and finance: Demonstrate knowledge and understanding of the
PO11 engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
Life-long learning: Recognize the need for, and have the preparation and ability to engage
PO12 in independent and life-long learning in the broadest context of technological change.
CCS342 DEVOPS LAB MANUAL

LIST OF PRACTICAL EXERCISES.


1. Create Maven Build pipeline in Azure.

2. Run regression tests using Maven Build pipeline in Azure.

3. Install Jenkins in Cloud.

4. Create CI pipeline using Jenkins.

5. Create a CD pipeline in Jenkins and deploy in Cloud.

6. Create an Ansible playbook for a simple web application infrastructure.

7. Build a simple application using Gradle.

8. Install Ansible and configure ansible roles and to write playbooks

TOTAL: 30 Periods
Exp No : 1
Create Maven Build Pipeline in Azure.
Date : 24-08-24

AIM:
To create an automated Maven build pipeline in Azure DevOps for efficient Java application
development.
ALGORITHM:
Step 1:Organization is created.
Step 2: Organization by clicking the new project button .
Step3: Create Pipeline.
Step4: Configure new project.

PROCEDURE:

1. Create a New Project:


 Log in to your Azure DevOps account.
2. Create a new project or use an existing one.
 Create a New Pipeline:
 In your project, navigate to the "Pipelines" section.
 Click on the "New Pipeline" button.
Select the repository where your Maven project is stored.
3. Configure Pipeline:
 Choose a template. You can start with an "Empty Job" if there's no specific template for your technology
stack.
 You'll be directed to the pipeline configuration page.
4. Configure the Build Steps:
 Define your agent pool, VM image, and other basic settings.
 Under "Agent Job 1," click on the "+" button to add a new task.
 Search for "Maven" and add the "Maven" task.
5. Configure the Maven Task:
 In the Maven task configuration, you'll need to provide the path to your pom.xml file and select the Maven
version you want to use.
 Choose the goals you want to run (e.g., clean install, package, etc.).
 Configure other options like Advanced options and Java options if needed.
6. Save and Queue:
 Save your pipeline configuration.
 Click on "Save & queue" to initiate the pipeline run.
 Review the pipeline run logs to ensure everything is running as expected.
7. Artifact Publishing (Optional):
 If your project generates an artifact (like a JAR or WAR file), you might want to publish it as an artifact that
can be used in subsequent stages or releases.
8. Triggers and Continuous Integration (CI) Setup:
 Configure triggers to automate pipeline runs. For example, you can trigger the pipeline whenever changes are
pushed to specific branches.
9. Environment-Specific Configuration (Optional):
 If you have different environments (like development, testing, production), you can set up multiple
stages in the pipeline to deploy to these environments.
OUTPUT:

Step 1:Organization is created.

Step 2: Organization by clicking the new project button .

Step3: Create Pipeline.


Step4: Configure new project.

RESULT:
Thus the above programmers Create Maven Build Pipeline in Azure executed successfully.
Exp No : 2
Run regression tests using Maven Build pipeline in Azure.
Date : 27-08-24

AIM:

To run regression tests using a Maven build pipeline in Azure.

ALGORITHM:

Step 1: Create a New Build Pipeline.


Step 2: Configure the Source Repository.
Step 3: Configure the Build Pipeline.
Step 4: Configure the Maven Task.
Step 5: Add Test Reporting (Optional).
Step 6: Save and Queue the Pipeline.
Step 7: Monitor the Build.
Step 8: Set Up Triggers (Optional).

PROCEDURE:
1: Create a New Build Pipeline
 Open your Azure DevOps project.
 Navigate to Pipelines > Builds.
 Click on the "+ New" button to create a new build pipeline.
2: Configure the Source Repository
 Select the repository where your Maven project is stored.
 Choose the branch you want to build.
3: Configure the Build Pipeline
Choose a template: Select "Maven" as the template for your pipeline.
4: Configure the Maven Task
 In the pipeline editor, you will see a task named "Maven" (or similar). Click on it to configure the
Maven task.
 In the "Goals" field, specify the Maven goals needed to run your regression tests. For example, if
your regression tests are part of the "integration-test" phase, you can enter: clean integration-test.
 Set other Maven-related configurations as needed (e.g., POM file, options).
5: Add Test Reporting (Optional)
 If your regression tests produce test reports, you might want to publish them in Azure DevOps.
 After the Maven task, add a task to publish the test reports. For example, if your tests generate
Surefire or Failsafe reports, you can use the "Publish Test Results" task and specify the path to the
test report XML files.
6: Save and Queue the Pipeline
After configuring the pipeline, click on "Save & Queue" to save your changes and trigger a
build.
7: Monitor the Build
 Once the pipeline is triggered, it will run the Maven build, including the regression tests.
 You can monitor the progress and results in the Azure DevOps pipeline interface.
8: Set Up Triggers (Optional)
 You can set up triggers to automatically run the build pipeline when changes are pushed to specific
branches.
 Configure branch filters and triggers according to your needs.
 Remember that Azure DevOps provides a flexible environment, and you can customize your pipeline
further to accommodate your specific project requirements.

OUTPUT:

Step1: New resource, select go to resource.

Step2: Azure Load Testing resource, select Tests


Step3: On the Basics tab, enter the Test name and Test description information.

RESULT:

Thus, the above programs completed run regression tests using a Maven build pipeline in Azure output is
verified successfully.
Exp No : 3
To install Jenkins in a Cloud Environment.
Date : 3-09-24

AIM:
The aim of installing Jenkins in the cloud is to automate and scale software development processes for
faster, reliable builds and deployments.

ALGORITHM:
Step 1: Create a Virtual Machine.
Step 2: Navigate to the EC2 service (Elastic Compute Cloud).
Step 3: Security Group Configuration.
Step 4: Connect to the Virtual Machine.
Step 5: Install Java.
Step 6: Install Jenkins.
Step 7: Access Jenkins Web Interface.
Step 8: Complete Jenkins Setup.
Step 9: Customize and Secure.

PROCEDURE :
Example: Installing Jenkins on a Virtual Machine in AWS
 Choose a Cloud Provider: Decide on a cloud provider that you want to use. For this example, let's
use Amazon Web Services (AWS).
1. Create a Virtual Machine:
 Log in to your AWS console.
 Navigate to the EC2 service (Elastic Compute Cloud).
 Click on "Launch Instances" to create a new virtual machine.
 Choose an Amazon Machine Image (AMI) that supports your desired operating system (e.g.,
Amazon Linux, Ubuntu Server).
 Configure the instance details (instance type, networking, etc.).
 Add storage as needed.
2. Security Group Configuration:
 Configure security groups to allow incoming traffic on the necessary ports. Jenkins typically uses
port 8080 for web access and optionally other ports for agents.
3. Connect to the Virtual Machine:
 Once the virtual machine is launched, connect to it using SSH.
 You can use the public IP address or DNS name provided by AWS.
4. Install Java:
 Jenkins requires Java to run. Install Java on the virtual machine using the package manager for your
chosen operating system.
5. Install Jenkins:
 Add the Jenkins repository to your package manager's sources.
 Install Jenkins using the package manager.
 Start the Jenkins service.
6. Access Jenkins Web Interface:
 Open a web browser and navigate to the public IP address or DNS name of your virtual machine,
followed by port 8080.
 You will need to enter the initial administrator password, which can be found on the virtual machine
in a file.
7. Complete Jenkins Setup:
 Follow the on-screen instructions to complete the Jenkins setup process.
 Install recommended plugins or select the plugins you need.
 Create an admin user account.
8. Customize and Secure:
 Configure Jenkins settings according to your preferences.
 Implement security measures, such as setting up authentication, authorization, and HTTPS.

OUTPUT:
Step1: Enter the IP Address in url:103.43.200.163
Step2: Sign in to the AWS Management Console.
Step3: Open the Amazon EC2 console
Step4: select Security Groups

Step5: choose Instances.

RESULT:

Thus the above install Jenkins in a cloud environment and completed successfully completed.
Exp No : 4 Creating a Continuous Integration (CI) pipeline using
Jenkins.
Date : 10-09-24

AIM:
To Creating a Continuous Integration (CI) pipeline using Jenkins.
ALGORITHM:
Step 1: Login into your Jenkins account as shown below.
Step 2: Once logged in, the user will be redirected to the Jenkins console.
Step 3: To create a new project, select the option.
Step 4: Now a list of options will be visible on the screen.
Step 5: Once redirected.

PROCEDURE :

Prerequisites:
 Jenkins installed and running.
 A version control system (e.g., Git) repository containing your code.
1. Steps to Create a CI Pipeline in Jenkins:
 Create a New Jenkins Job:
 Log in to your Jenkins dashboard.
 Click on "New Item" to create a new job.
 Enter a name for your job (e.g., "McJob") and select the "Pipeline" option.
2. Configure Pipeline:
 In the pipeline section, select "Pipeline script" from the Definition dropdown.
 You can write your pipeline script directly in the Jenkins UI or load it from a Jenkins file located in your
version control repository.
3. Write the Pipeline Script:
 Below is a basic example of a Jenkins pipeline script that checks out code, builds it, and runs tests. Customize
it according to your project's needs.
pipeline {
agent any
stages { stage('Checkout') {
steps { checkout sum
}}
stage('Build') {steps {
// Replace with your build commands (e.g., compiling, packaging)
sh 'echo "Building"'
}}
stage('Test') { steps {
// Replace with your test commands (e.g., unit tests, integration tests)
sh 'echo "Testing"'
} } }}
(e.g., unit tests, integration tests) sh 'echo "Testing"' } } } }
4. Save and Run:
 Save your pipeline configuration.
 Click on "Build Now" to trigger the pipeline.
 Jenkins will run the pipeline steps defined in your script.
5. View Pipeline Results:
 You can view the progress and results of your pipeline by clicking on the job name and selecting a specific
build number.
 Jenkins will display the console output and the status of each stage.

6. Adding Additional Steps:


You can expand your pipeline to include additional stages such as deployment, code analysis, and notifications.

OUTPUT:
Step 1: Login into your Jenkins account as shown below.
Step 2: Once logged in, the user will be redirected to the Jenkins console,
Step 3: To create a new project, select the option.
Step 4: Now a list of options will be visible on the screen.
Step 5: Once redirected.

RESULT:

Thus the above program Creating a Continuous Integration (CI) pipeline using Jenkins.
Exp No: 5 Create a CD pipeline in Jenkins and deploy in Cloud.
Date : 24-09-24

AIM:
To Create a CD pipeline in Jenkins and deploy in Cloud.

ALGORITHM:
Step1: Click on Freestyle project.
Step2: Source Code Management window.
Step3: Jenkins needs to fetch all the repository files.
Step4: Go to the Build tab and add the build step .
Step5: Drop- down file menu.
Step 6: Build Now.

PROCEDURE :
1. Prerequisites:
 Jenkins installed and running.
 AWS account and Elastic Beanstalk environment set up.
 Your code hosted in a version control repository (e.g., GitHub).
Here's a high-level overview of the steps to create the pipeline:
2. Set Up Jenkins Job:
 Log in to your Jenkins instance.
 Create a new pipeline job.
 In the pipeline configuration, choose your version control system (e.g., Git) and provide the
repository URL.
 Configure Jenkins file: Create a Jenkins file in your repository's root directory. This file defines the
pipeline stages and steps.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
// Perform build steps (e.g., compile code, package artifacts)
}
}
stage('Deploy') {
steps {
// Deploy to cloud environment (e.g., AWS Elastic Beanstalk)
sh '''
aws configure set aws_access_key_id <your_access_key>
aws configure set aws_secret_access_key <your_secret_key>
eb init <your_eb_app_name> -p <your_eb_platform>
eb deploy
'''
}
}
}
}

 Replace placeholders (<your_access_key>, <your_secret_key>, <your_eb_app_name>,


<your_eb_platform>) with your actual AWS credentials and Elastic Beanstalk information.
 Install Required Plugins: Depending on your cloud provider and tools, you might need additional
plugins in Jenkins. For AWS Elastic Beanstalk, you'd need the "AWS Elastic Beanstalk" plugin.
3. Configure AWS Credentials in Jenkins:
 Go to Jenkins Dashboard > Credentials > System.
 Add new AWS credentials with access key and secret key.
4. Run the Pipeline:
Trigger the pipeline manually or configure webhooks to trigger it automatically on code changes.
OUT PUT:
RESULT:
Thus the above program was successfully completed CD pipeline in Jenkins and deploy in Cloud.
Exp No : 6
Create an Ansible playbook for a simple web application
Date : 1-10-24
infrastructure.

AIM:
To create simple Ansible playbook for setting up a basic web application.

ALGORITHM:
Step 1: Gather facts about the target hosts.
Step 2: Update the package cache based on the OS family (Debian or RedHat).
Step 3: Preconfigure MySQL root password (for Debian-based systems).
Step 4: Install required packages (nginx and MySQL-server) based on the OS family.
Step 5: Start and enable the nginx service.
Step 6: Start and enable the MySQL service.
Step 7: Copy the Nginx configuration file to the target machine.
Step 8: Restart the nginx service if configuration changes are made.
Step 9: Create a MySQL database for the web application.
Step10: Display the execution summary of all tasks.

PROCEDURE:
1. name: Setup Web Application Infrastructure
 hosts: all
 become: yes

2. tasks:
name: Update apt cache (Ubuntu) or yum cache (CentOS)
 apt:
 update cache: yes
 when: ansible_os_family == "Debian"

3: name: Install required packages


 apt:
 name:
 nginx
 mysql-server
 state: present
 when: ansible_os_family == "Debian"

3. name: Install required packages


 yum:
 name:
- nginx
- mysql-server
 state: present
 when: ansible_os_family == "RedHat"

4. name: Start and enable services


 service:
 name:
- nginx
- mysql
 state: started
 enabled: yes

5. name: Copy nginx configuration file


 copy:
 src: files/nginx.conf
 dest: /etc/nginx/nginx.conf
 notify:
- Restart Nginx

6. name: Ensure MySQL root password is set


 debconf:
 name: mysql-server
 question: mysql-server/root_password
 value: "{{ mysql_root_password }}"
 vtype: password
 become: yes

7. name: Create database for the web application


 mysql_db:
 name: mywebapp
 state: present
 become: yes
 handlers:name: Restart Nginx
 service:
 name: nginx
 state: restarted

OUTPUT:
Setup Web Application Infrastructure
Gathering Facts =ok: [all]
Update apt cache (Ubuntu) =changed: [all]
Preconfigure MySQL root password (Debian)=changed: [all]
Preconfigure MySQL root password again for confirmation (Debian)=changed: [all]
Install required packages (Debian)=changed: [all]
Start and enable Nginx service =changed: [all]
Start and enable MySQL service =changed: [all]
Copy nginx configuration file]=changed: [all]
Create database for the web application=changed: [all]
RUNNING HANDLER [Restart Nginx] =changed: [all]
PLAY RECAP all : ok=10 changed=8 unreachable=0 failed=0 skipped=0 rescued=0
ignored=0

RESULT:

Thus the above program are successfully Create an Ansible playbook for a simple web application infrastructure.
Exp No : 7
Build a simple application using Gradle.
Date : 15-10-24

AIM :
To build a simple application using Gradle.
ALGORITHM:
Step 1:Create a Project Directory.
Step 2:Navigate to the Project Directory.
Step 3:Create the build. Gradle File.
Step 4:Create the src Directory.
Step 5:Create Package Directory Structure.
Step 6:Add Java Code.
Step 7:Run Gradle Wrapper Command.

PROCEDURE:

1. Create a Project Directory:


 Create a new folder for the project (e.g., MyGradleProject).
2. Navigate to the Project Directory:
 Open a terminal and move into the project directory.
3. Create the build. Gradle File:
Inside the project directory, create a file named build. Gradle.
Add the following content.
apply plugin: 'java'

repositories {
jcenter()
}
dependencies {
compile 'com.google.guava:guava:30.1-jre'
}
source Sets {
main {
java {
srcDir 'src'
}
}
}
4. Create the src Directory:
 In the project directory, create a folder named src.
5. Create Package Directory Structure:
 Inside the src folder, create subdirectories that match your package name (e.g., com/example).
6. Add Java Code:
 Inside the com/example directory, create a file named Main.java.
package com.example;
import com.google.common.base.Joiner;

public class Main {


public static void main(String[] args) {
String[] words = {"Hello", "Gradle"};
String joinedWords = Joiner.on(" ").join(words);
System.out.println(joinedWords);
}
}
7. Run Gradle Wrapper Command:
 Open a terminal in the project directory.
 Run the command to execute the program.
./gradlew run

OUTPUT:

Hello Gradle.

RESULT:
Thus the above programs are building a simple application using Gradle successfully completed.
Exp No: 8
Install ansible and configure ansible roles and to write
Date: 29-10-24
playbooks.

AIM:
To Install Ansible and configure ansible roles and to write playbooks.

ALGORITHM:
Step 1: Install Ansible.
Step 2: Create Project Directory Structure.
Step 3: Define Target Hosts.
Step 4: Initialize a Role.
Step 5: Edit Role Tasks.
Step 6: Create an Ansible Playbook.
Step 7: Run the Playbook.

PROCEDURE:

1. Installing Ansible:
2. For Ubuntu/Debian:
 sudo apt update
 sudo apt install ansible

3. For CentOS/RHEL:
 sudo yum install epel-release
 sudo yum install ansible

4. For macOS:
brew install ansible.
5. For Windows:
 You can use Windows Subsystem for Linux (WSL) or install Ansible in a Linux virtual machine.
 Ansible Directory Structure.
 Create a directory structure for your Ansible project.
 Plaintext.
 ansible_project/
|-- inventory/
| |-- hosts
|-- roles/
|-- playbooks/
|-- ansible.cfg
 inventory: This directory contains your inventory file where you define the hosts you want to manage.
 roles: This directory will hold your Ansible roles.
 playbooks: This directory will contain your Ansible playbooks.
 ansible.cfg: Ansible configuration file.
 Writing an Ansible Role:
6. Inside the roles directory, create a new role:
 ansible-galaxy init my_role.
 This will create a basic directory structure for your role.
7. Writing an Ansible Playbook:
 Create a playbook inside the playbooks directory. For example, create a file named my_playbook.yml.
 name: My Ansible Playbook.
 hosts: your_target_host_group.
 become: yes
 roles:
- my role
 Replace your_target_host_group with the group of hosts defined in your inventory.
8. Running the Ansible Playbook:
 Run the playbook using the following command.
 ansible-playbook -I inventory/hosts playbooks/my_playbook.yml.

OUTPUT:
My Ansible Playbook
Gathering Facts=ok: [192.168.1.10]
my role : Install Apache =changed: [192.168.1.10]
PLAY RECAP
192.168.1.10 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

RESULT:
Thus the above program Install Ansible and configure ansible roles and to write playbooks in successfully.

You might also like