06PART 1: Install Ansible
Step 1: Open Ubuntu Terminal
Open Ubuntu/WSL terminal.
Step 2: Update System Packages
Run:
sudo apt update
Enter password if asked.
Step 3: Install Ansible
Run:
sudo apt install ansible -y
Wait for installation.
Step 4: Verify Installation
Check version:
ansible --version
If version appears, Ansible installed
successfully.
PART 2: Create Inventory File
Inventory file tells Ansible which machine
to manage.
Step 1: Create Hosts File
Run:
nano hosts
Add:
localhost ansible_connection=local
Save file:
CTRL + O → Enter → CTRL + X
Step 2: Verify Hosts File
Run:
cat hosts
Output:
localhost ansible_connection=local
PART 3: Create Simple Test Playbook
Step 1: Create YAML File
Run:
nano [Link]
Paste:
---
- name: Test Playbook
hosts: all
tasks:
- name: Print message
debug:
msg: "Ansible is working"
Save file.
Step 2: Run Playbook
Run:
ansible-playbook -i hosts [Link]
Step 3: Verify Output
You should see:
msg: "Ansible is working"
This means Ansible is working properly.
Step 4: List Files
Run:
ls
You should see:
hosts [Link]
PART 4: Install Apache using Ansible
Playbook
Problem Statement
Create Ansible Playbook to:
1. Install Apache Web Server
2. Start Apache Service
3. Display Success Message
Step 1: Create Apache Playbook
Run:
nano [Link]
Paste this complete code:
---
- name: Install Apache Server
hosts: all
become: yes
tasks:
- name: Install Apache
apt:
name: apache2
state: present
update_cache: yes
- name: Start Apache Service
service:
name: apache2
state: started
enabled: yes
- name: Show success message
debug:
msg: "Apache installed and running
successfully!"
Save file.
Step 2: Verify File
Run:
cat [Link]
Step 3: Run Apache Playbook
Run:
ansible-playbook -i hosts [Link]
Enter password if asked.
Step 4: Check Output
You should see:
Apache installed and running
successfully!
Step 5: Verify Apache in Browser
Open browser:
[Link]
You should see:
Apache2 Ubuntu Default Page
Apache server running successfully.
PART 5: Create Cron Job using Shell
Script
Step 1: Create Shell Script
Run:
nano [Link]
Paste:
#!/bin/bash
echo "Script ran at $(date)" >>
/home/$USER/[Link]
Save file.
Step 2: Give Execute Permission
Run:
chmod +x /home/$USER/[Link]
Step 3: Open Crontab
Run:
crontab -e
If editor selection appears:
Choose:
1
For nano editor.
Step 4: Add Cron Job
At bottom add:
* * * * * /home/$USER/[Link] >>
/home/$USER/[Link] 2>&1
Meaning:
Sym Meani
bol ng
* * * * Every
* minut
e
mys Script
cript. to run
sh
log.t Store
xt logs
Save and exit.
Step 5: Verify Cron Job
Run:
crontab -l
You should see:
* * * * * /home/username/[Link] >>
/home/username/[Link] 2>&1
Step 6: Wait 1 Minute
Cron runs automatically every minute.
Step 7: Check Output File
Run:
cat /home/$USER/[Link]
Output example:
Script ran at Tue May 5 17:16:02 UTC 2026
Step 8: Check Log File
Run:
cat /home/$USER/[Link]
Common Error: Permission Denied
If you see:
Permission denied
Fix using:
chmod +x [Link]
05Docker Lab Assignments – Complete
Step-by-Step Guide (Beginner Friendly)
This guide is written in very simple language so you can follow each step without confusion.
Before Starting
Step 1: Install Docker Desktop
Download and install:
Docker Desktop
After installation:
● Open Docker Desktop
● Wait until it says Docker is running
Open Terminal / PowerShell
Press:
● Windows + R
● Type powershell
● Press Enter
Now you are ready.
Assignment 1: Run Your First Docker
Container
Step 1: Run hello-world Container
Type this command:
docker run hello-world
What Happens?
Docker will:
1. Download the hello-world image
2. Create a container
3. Run it
4. Show a success message
Expected Output
You will see something like:
Hello from Docker!
This message shows that your installation appears to be working correctly.
That means Docker is working successfully.
Assignment 2: Run NGINX Web Server
NGINX is a web server.
Step 1: Run NGINX Container
Type:
docker run -d -p 8080:80 nginx
Meaning of Command
Part Meaning
docker run Run a container
-d Run in background
-p 8080:80 Connect local port 8080 to container port
80
nginx NGINX image
Step 2: Open Browser
Open:
[Link]
You should see:
Welcome to nginx!
Step 3: Check Running Containers
Type:
docker ps
You will see container details.
Assignment 3: Create Your Own Docker
Image
Now you will create your own custom website.
Step 1: Create Project Folder
In PowerShell:
mkdir myapp
Move inside folder:
cd myapp
Step 2: Create [Link] File
Open Notepad:
notepad [Link]
If asked to create file, click Yes.
Paste this:
<h1>Hello DevOps Lab</h1>
Save and close.
Step 3: Create Dockerfile
Open Dockerfile:
notepad Dockerfile
Paste this:
FROM nginx:latest
COPY [Link] /usr/share/nginx/html/[Link]
Save and close.
04DevOps Lab Assignment – Jenkins,
GitHub & CI/CD
This is the quickest possible method to finish the entire practical.
PART 1 — GitHub + GitLab CI/CD
Step 1: Install Required Software
Install only:
● Git
● Jenkins
● Java
Create accounts on:
● GitHub
● GitLab
Step 2: Create GitHub Repo Quickly
Open PowerShell:
mkdir lab
cd lab
git init
echo Hello > [Link]
git add .
git commit -m "first"
Create empty repo on GitHub named:
lab
Then run:
git remote add origin [Link]
git branch -M main
git push -u origin main
DONE ✅
Step 3: GitLab CI/CD (Fastest)
Create GitLab project:
gitlab-lab
Clone it:
git clone [Link]
cd gitlab-lab
Create pipeline file:
notepad .[Link]
Paste:
test-job:
script:
- echo "Hello from GitLab CI/CD!"
Push:
git add .
git commit -m "pipeline"
git push
DONE ✅
Pipeline automatically runs.
PART 2 — Jenkins Practical (FASTEST)
Step 1: Open Jenkins
After installation open:
[Link]
Install suggested plugins.
Step 2: Install ONE Extra Plugin
Go:
Manage Jenkins → Plugins
Install:
Email Extension Plugin
Restart Jenkins.
Step 3: Create Pipeline Project
● New Item
● Name: lab-pipeline
● Select: Pipeline
● OK
Step 4: Add Pipeline Script Directly
Inside Jenkins job:
Configure → Pipeline
Select:
Pipeline script
Paste this COMPLETE code:
pipeline {
agent any
stages {
stage('Build') {
steps {
bat 'echo Hello Jenkins > [Link]'
}
}
stage('Create Report') {
steps {
bat '''
if not exist report mkdir report
echo ^<h1^>Build Success^</h1^> > report\\[Link]
'''
}
}
stage('Deploy') {
steps {
bat 'if not exist C:\\deploy mkdir C:\\deploy'
bat 'copy report\\[Link] C:\\deploy\\[Link]'
}
}
}
post {
success {
emailext(
to: 'YOURMAIL@[Link]',
subject: 'Build Success',
body: 'Pipeline Success'
)
}
failure {
emailext(
to: 'YOURMAIL@[Link]',
subject: 'Build Failed',
body: 'Pipeline Failed'
)
}
}
}
Save.
Step 5: Configure Email (Quick)
Go:
Manage Jenkins → Configure System
Find:
Extended E-mail Notification
Fill:
Field Value
SMTP Server [Link]
Port 587
Username your gmail
Password Gmail App Password
TLS Enable
Save.
Step 6: Generate Gmail App Password
Go:
Google Security
Enable:
2-Step Verification
Then:
App Passwords
Generate password and use it in Jenkins.
Step 7: Run Pipeline
Click:
Build Now
DONE ✅
03Task 1: Jenkins Installation – Detailed
Steps from Scratch
Step 1: Install Java
Jenkins requires Java to run.
Download Java
Open:
Java Download (Adoptium)
Download:
JDK 17 (Windows x64 MSI)
Install using default settings.
Step 2: Verify Java Installation
Open PowerShell:
java -version
You should see Java version details.
Step 3: Download Jenkins
Open:
Jenkins Download
Download:
Windows Installer (.msi)
Step 4: Install Jenkins
Run Jenkins installer.
Click:
Next → Install → Finish
Use default settings.
Jenkins service starts automatically.
Step 5: Open Jenkins
Open browser:
[Link]
Step 6: Unlock Jenkins
Open this file:
C:\Program Files\Jenkins\secrets\initialAdminPassword
Copy password.
Paste into Jenkins browser page.
Click:
Continue
Step 7: Install Plugins
Click:
Install Suggested Plugins
Wait for installation.
Step 8: Create Admin User
Fill:
Field Example
Usernam admin
e
Password admin123
Email your email
Click:
Save and Continue
Jenkins dashboard opens successfully.
Task 2: Automate File Creation and Script
Execution Using Jenkins Jobs
Step 1: Create Freestyle Project
On Jenkins dashboard:
1. Click:
New Item
2. Enter name:
FileJob
3. Select:
Freestyle Project
4. Click:
OK
Step 2: Add Build Step
Scroll to:
Build
Click:
Add Build Step → Execute Windows batch command
Paste:
mkdir C:\jenkins-demo
echo Hello from Jenkins Script > C:\jenkins-demo\[Link]
echo Current Date:
date /t >> C:\jenkins-demo\[Link]
echo Current Time:
time /t >> C:\jenkins-demo\[Link]
echo Hello from Jenkins Script
Step 3: Save Job
Click:
Save
Step 4: Run Job
Click:
Build Now
Step 5: Check Output
Click build number → Console Output
You should see:
Hello from Jenkins Script
Check folder:
C:\jenkins-demo
You will see:
[Link]
Task 3: Run Basic Jenkins Pipeline
Step 1: Create Pipeline Job
Dashboard → New Item
Enter:
PipelineDemo
Select:
Pipeline
Click:
OK
Step 2: Add Pipeline Script
Scroll to:
Pipeline
Select:
Pipeline script
Paste:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Build Stage Running'
}
}
stage('Execute') {
steps {
echo 'Execution Stage Running'
}
}
}
}
Step 3: Save Pipeline
Click:
Save
Step 4: Run Pipeline
Click:
Build Now
Step 5: View Console Output
Open build number → Console Output
You will see:
Build Stage Running
Execution Stage Running
Task 4: Integrating Jenkins with GitHub
(with Timer)
Step 1: Install Git
Download:
Git Download
Install with default settings.
Step 2: Create GitHub Repository
Open:
GitHub
Create repository:
jenkins-github-demo
Step 3: Create Local Project
Open PowerShell:
mkdir github-demo
cd github-demo
Create file:
notepad [Link]
Add:
<h1>Hello Jenkins GitHub</h1>
Save.
Step 4: Push Code to GitHub
Initialize Git:
git init
git add .
git commit -m "first commit"
Connect GitHub repo:
git remote add origin [Link]
Push:
git branch -M main
git push -u origin main
Step 5: Create Jenkins Job
Dashboard → New Item
Name:
gitRepoP1
Select:
Freestyle Project
Click OK.
Step 6: Connect GitHub Repo
Under:
Source Code Management
Select:
Git
Paste repository URL:
[Link]
Branch:
*/main
Step 7: Add Build Trigger
Enable:
Build periodically
Add:
H/2 * * * *
Meaning:
Run every 2 minutes
Step 8: Save and Build
Click:
Save
Then:
Build Now
Jenkins fetches GitHub code automatically.
Task 5: Build and Deploy Web Application
to Local HTTP Server
Step 1: Create Web App Folder
Open PowerShell:
mkdir webapp-project
cd webapp-project
Step 2: Create HTML File
notepad [Link]
Paste:
<html>
<body>
<h1>Hello from Jenkins Web App</h1>
</body>
</html>
Save.
Step 3: Create Pipeline Job
Dashboard → New Item
Name:
Build+deploy
Select:
Pipeline
Click OK.
Step 4: Add Pipeline Script
Paste:
pipeline {
agent any
stages {
stage('Build') {
steps {
writeFile file: '[Link]', text: '<h1>Hello from Jenkins roll_33</h1>'
}
}
stage('Deploy') {
steps {
bat 'mkdir C:\\webapp'
bat 'copy [Link] C:\\webapp\\[Link]'
}
}
}
}
Step 5: Save Pipeline
Click:
Save
Step 6: Run Pipeline
Click:
Build Now
Step 7: Verify Deployment
Open:
C:\webapp
You will see:
[Link]
Double-click file.
Browser shows:
Hello from Jenkins roll_33
02GitLab Assignment – Detailed
Step-by-Step Guide from Scratch
This assignment helps in learning:
● GitLab repository creation
● SSH key setup
● GitLab Web IDE
● Branching and Merge Requests
● GitLab CI/CD pipelines
● Cherry-pick operation in Git
Part 1: Setting Up GitLab Repository and
SSH Key
Step 1: Create GitLab Account
Open:
GitLab
Create account and login.
Step 2: Create New GitLab Repository
After login:
1. Click:
New Project
2. Select:
Create Blank Project
3. Enter project name:
my-gitlab-project
4. Select visibility:
● Private
● Public
● Internal
5. Click:
Create Project
Repository created successfully.
Step 3: Install Git
Download Git:
Git Download
Install with default settings.
Step 4: Generate SSH Key
Open Git Bash.
Run:
ssh-keygen -t ed25519 -C "your-email@[Link]"
Example:
ssh-keygen -t ed25519 -C "abc@[Link]"
Press Enter for all default options.
SSH key generated successfully.
Step 5: Locate SSH Key
Open folder:
%userprofile%\.ssh
You will see:
id_ed25519
id_ed25519.pub
Step 6: Add SSH Key to GitLab
Open:
GitLab SSH Keys
Open:
id_ed25519.pub
Copy complete key.
Paste into GitLab SSH Key section.
Click:
Add Key
Step 7: Configure Git
Open Git Bash:
git config --global [Link] "Your Name"
Example:
git config --global [Link] "Harshit"
Set email:
git config --global [Link] "your-email@[Link]"
Example:
git config --global [Link] "abc@[Link]"
Part 2: GitLab Basic Operations
Step 1: Clone Repository
Copy SSH repository URL from GitLab.
Example:
git@[Link]:username/[Link]
Clone repository:
git clone git@[Link]:username/[Link]
Move inside project:
cd my-gitlab-project
Step 2: Create New Branch
Create branch:
git checkout -b login-feature
Branch created successfully.
Step 3: Create HTML File
Create file:
notepad [Link]
Add:
<html>
<body>
<h1>GitLab Project</h1>
</body>
</html>
Save file.
Step 4: Add and Commit Changes
Stage file:
git add [Link]
Commit:
git commit -m "Added [Link] file"
Step 5: Push Branch to GitLab
Push branch:
git push origin login-feature
Branch uploaded successfully.
Step 6: Create Merge Request (MR)
Open GitLab project.
Go to:
Merge Requests → New Merge Request
Select:
Option Value
Source login-feature
Branch
Target Branch main
Add title and description.
Click:
Create Merge Request
Then click:
Merge
Changes merged successfully.
Part 3: GitLab CI/CD Pipeline
Step 1: Enable Shared Runner
Go to:
Settings → CI/CD
Expand:
Runners
Enable:
Shared Runners
Step 2: Create CI/CD File
Create file:
notepad .[Link]
Paste:
stages:
- build
build-job:
stage: build
script:
- echo "Hello from GitLab CI/CD!"
Save file.
Step 3: Commit Pipeline File
Add:
git add .[Link]
Commit:
git commit -m "Added GitLab CI/CD pipeline"
Push:
git push origin main
Step 4: Run Pipeline
Go to:
CI/CD → Pipelines
Pipeline starts automatically.
You will see:
Pipeline Passed
Output:
Hello from GitLab CI/CD!
Part 4: Advanced Git Operations
(Cherry-Pick)
Step 1: Create New Branch
Create new branch:
git checkout -b feature-cicd
Step 2: Modify HTML File
Open:
notepad [Link]
Update content:
<h1>Updated using feature-cicd branch</h1>
Save file.
Step 3: Commit Changes
Add:
git add [Link]
Commit:
git commit -m "Updated [Link]"
Push:
git push origin feature-cicd
Step 4: View Commit History
Run:
git log --oneline
Example output:
09ab6b8 Updated [Link]
Copy commit hash:
09ab6b8
Step 5: Switch to Main Branch
git checkout main
Step 6: Cherry-Pick Commit
Run:
git cherry-pick 09ab6b8
Git copies that commit to main branch.
Step 7: Push Changes
Push updated main branch:
git push origin main
Cherry-pick completed successfully.