EXPERIMENT 1
AIM: To understand DevOps principles,
practices, and the role & responsibilities of
a DevOps engineer.
Theory:
DevOps is a modern software engineering culture and set of practices that integrate
Development (Dev) and Operations (Ops) teams. The primary goal of DevOps is to
increase the speed, quality, and reliability of software delivery by improving
collaboration, automation, and continuous feedback across all stages of the application
lifecycle.
DevOps focuses on removing the traditional barriers between developers and operations
teams so that software can be built, tested, released, and monitored in a smoother and more
efficient manner.
Core Principles of DevOps
1. Collaboration and Communication
DevOps emphasizes strong communication between developers, testers, operations, and
business teams. This reduces misunderstandings, speeds up releases, and ensures
everyone works toward a common goal.
2. Automation
Automation is a key pillar of DevOps. Activities such as building code, running tests,
deploying applications, configuring servers, and monitoring performance are automated to
reduce manual errors and ensure consistency.
3. Continuous Integration (CI)
Developers merge their code frequently into a shared repository. Automated build and test
systems validate the changes, ensuring early detection of errors.
4. Continuous Delivery (CD)
Software is continuously tested, packaged, and prepared for deployment. Deployment
becomes faster and more reliable, enabling frequent releases.
5. Continuous Monitoring and Feedback
After deployment, application performance and infrastructure health are continuously
monitored. Feedback from monitoring tools helps engineers rapidly identify issues and
improve future releases.
6. Infrastructure as Code (IaC)
Servers, networks, and infrastructure configurations are managed using code instead of
manual setups. Tools like Terraform, Ansible, and Puppet help automate provisioning and
configuration.
Key DevOps Practices
1. Version Control Systems (Git)
2. Automated Build Systems (Maven, Gradle)
3. CI/CD Pipelines (Jenkins, GitHub Actions, GitLab CI)
4. Containerization (Docker)
5. Container Orchestration (Kubernetes)
6. Monitoring & Logging (Prometheus, Grafana, ELK Stack)
These practices work together to create a fast, stable, and repeatable software delivery
process.
Role and Responsibilities of a DevOps Engineer
A DevOps engineer bridges the gap between development and operations by:
1. Automating CI/CD Pipelines
Creating automated workflows for building, testing, and deploying applications.
2. Managing Source Code Repositories
Working with Git, branching strategies, and code integration.
3. Provisioning and Managing Infrastructure
Using Infrastructure-as-Code tools (Terraform, Ansible, Puppet, Chef).
4. Deploying and Managing Containers
Using Docker and Kubernetes for scalable application deployment.
5. Monitoring Applications and Infrastructure
Integrating monitoring systems to track performance, reliability, and failures.
6. Ensuring Security and Compliance
Implementing secure CI/CD pipelines, automated security scans, and access control
measures.
7. Collaboration with Development and Operations Teams
Helping teams adopt DevOps practices and troubleshooting deployment issues.
Conclusion
DevOps is not a tool or technology but a culture and methodology that enhances
collaboration, automation, and continuous improvement. A DevOps engineer plays a crucial
role in enabling faster software releases, improving system reliability, and supporting
scalable application environments.
EXPERIMENT 2
AIM: Install Git and create/configure a
GitHub account and local Git identity
# Install Git (Linux - apt example)
sudo apt update
sudo apt install -y git
# Verify installation
git --version
# Configure user
git config --global [Link] "Your Name"
git config --global [Link] "you@[Link]"
# Create SSH key and add to GitHub (optional, recommended)
ssh-keygen -t ed25519 -C "you@[Link]"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub # copy this and add to GitHub SSH keys
EXPERIMENT 3
AIM: Perform common Git operations on
local and remote repositories using a Git
cheat-sheet.
# Initialize and basic workflow
git init
git status
git add .
git commit -m "Initial commit"
# Create or add remote and push
git remote add origin git@[Link]:username/[Link]
git branch -M main
git push -u origin main
# Common operations
git clone git@[Link]:username/[Link]
git fetch origin
git pull origin main
git checkout -b feature/my-feature
git merge main
git rebase main
git log --oneline --graph --decorate
git stash
git stash pop
# Delete remote branch
git push origin --delete feature/old
EXPERIMENT 4
AIM: Install and configure Jenkins, and
run a Maven/Ant/Gradle build job.
# Install Java (required by Jenkins)
sudo apt update
sudo apt install -y openjdk-17-jdk
# Add Jenkins repository and install
curl -fsSL [Link] | sudo tee \
/usr/share/keyrings/[Link] > /dev/null
echo "deb [signed-by=/usr/share/keyrings/[Link]] [Link]
stable binary/" | \
sudo tee /etc/apt/[Link].d/[Link]
sudo apt update
sudo apt install -y jenkins
# Start and enable Jenkins
sudo systemctl enable --now jenkins
sudo systemctl status jenkins
# Example: Maven build from command line (to be configured as build step in Jenkins)
cd /path/to/your/maven/project
mvn clean package
EXPERIMENT 5
AIM: Build a Jenkins pipeline using
Maven/Gradle/Ant to test and deploy an
application to a Tomcat server.
pipeline {
agent any
environment {
DEPLOY_PATH = "/opt/tomcat/webapps"
stages {
stage('Checkout') {
steps {
checkout scm
stage('Build') {
steps {
sh 'mvn clean package -DskipTests=false'
stage('Test') {
steps {
sh 'mvn test'
}
stage('Deploy') {
steps {
// assumes artifact is target/[Link]
sh "cp target/*.war ${DEPLOY_PATH}/"
post {
success { echo "Pipeline completed successfully" }
failure { echo "Pipeline failed" }
}
EXPERIMENT 6
AIM: Understand Jenkins master-slave
(controller-agent) architecture and
configure agent(slave) nodes.
# On Jenkins controller: Manage Nodes -> New Node -> create agent and obtain the
[Link] and secret/jnlp URL.
# On agent machine:
sudo apt update && sudo apt install -y openjdk-17-jdk
# Create agent folder
mkdir -p /opt/jenkins-agent && cd /opt/jenkins-agent
# Download [Link] (use URL from Jenkins)
wget [Link]
# Run agent with JNLP secret (replace <jnlp-url> and <secret>)
java -jar [Link] -jnlpUrl "[Link]
-secret "xxxxxxxx"
# Optionally run agent as systemd service (example service file):
sudo tee /etc/systemd/system/[Link] <<'EOF'
[Unit]
Description=Jenkins Agent
After=[Link]
[Service]
User=jenkins
WorkingDirectory=/opt/jenkins-agent
ExecStart=/usr/bin/java -jar /opt/jenkins-agent/[Link] -jnlpUrl
"[Link] -secret "xxxxxxxx"
Restart=always
[Install]
WantedBy=[Link]
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now jenkins-agent
EXPERIMENT 7
AIM: Setup and run Selenium tests in
Jenkins using Maven.
#Maven project skeleton
<!-- [Link] (relevant parts) -->
<project>
...
<dependencies>
<dependency>
<groupId>[Link]</groupId>
<artifactId>selenium-java</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>[Link]</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</plugin>
</plugins>
</build>
</project>
#Sample Selenium test in Java
// src/test/java/com/example/[Link]
import [Link].*;
import [Link].*;
import [Link];
public class SimpleSeleniumTest {
WebDriver driver;
@BeforeClass
public void setup() {
[Link]("[Link]", "/path/to/chromedriver");
driver = new ChromeDriver();
@Test
public void openGoogle() {
[Link]("[Link]
String title = [Link]();
assert [Link]("Google");
@AfterClass
public void teardown() {
if (driver != null) [Link]();
}
EXPERIMENT 8
AIM: Understand Docker architecture and
container lifecycle; install Docker and
manage images/containers.
# Install Docker (Ubuntu example)
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
curl -fsSL [Link] | sudo gpg --dearmor -o
/usr/share/keyrings/[Link]
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-
[Link]] \
[Link] $(lsb_release -cs) stable" | \
sudo tee /etc/apt/[Link].d/[Link] > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli [Link]
# Basic Docker commands
docker --version
sudo usermod -aG docker $USER # optional: allow running docker without sudo (log out/in)
docker pull nginx
docker run -d --name my-nginx -p 8080:80 nginx
docker ps
docker logs my-nginx
docker exec -it my-nginx /bin/bash
docker stop my-nginx
docker rm my-nginx
docker rmi nginx
EXPERIMENT 9
AIM: Learn Dockerfile instructions and
build an image for a sample web
application.
Code / Commands (example [Link] app Dockerfile + build/run commands):
Dockerfile
# Use official Node image
FROM node:18-alpine
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm ci --only=production
# Bundle app source
COPY . .
# Expose port and start app
EXPOSE 3000
CMD ["node", "[Link]"]
Build and run:
# Build image
docker build -t mynodeapp:1.0 .
# Run container
docker run -d --name mynodeapp -p 3000:3000 mynodeapp:1.0
Alternative simple Dockerfile for a static site (nginx):
FROM nginx:alpine
COPY ./dist /usr/share/nginx/html
EXPERIMENT 10
AIM: Install and configure pull-based
configuration management and
provisioning using Puppet.
Code / Commands (install Puppet agent & simple manifest example):
Install Puppet agent (Ubuntu example):
# Add Puppet repo and install agent
wget [Link]
sudo dpkg -i [Link]
sudo apt update
sudo apt install -y puppet-agent
# Check puppet version
/opt/puppetlabs/bin/puppet --version
# Run agent in test mode (requires puppetserver or master configured)
sudo /opt/puppetlabs/bin/puppet agent -t
Simple Puppet manifest ([Link]) example to install and start nginx:
# /etc/puppetlabs/code/environments/production/manifests/[Link]
node default {
package { 'nginx':
ensure => installed,
}
service { 'nginx':
ensure => running,
enable => true,
require => Package['nginx'],
}
file { '/var/www/html/[Link]':
ensure => file,
content => "<h1>Managed by Puppet</h1>",
require => Package['nginx'],
}
}
Apply manifest locally (with Puppet apply):
sudo /opt/puppetlabs/bin/puppet apply
/etc/puppetlabs/code/environments/production/manifests/[Link]