0% found this document useful (0 votes)
52 views28 pages

DevOps Essentials: AWS, GCP, Azure, Git

The document provides an overview of DevOps practices, cloud platforms (AWS, GCP, Azure), version control with Git and GitHub, build automation using Maven and Gradle, continuous integration with Jenkins, and configuration management with Ansible. It details the goals and components of DevOps, installation and configuration of tools, and key commands and concepts for each technology. The document serves as a comprehensive guide for understanding and implementing DevOps methodologies and tools.

Uploaded by

prakasherg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views28 pages

DevOps Essentials: AWS, GCP, Azure, Git

The document provides an overview of DevOps practices, cloud platforms (AWS, GCP, Azure), version control with Git and GitHub, build automation using Maven and Gradle, continuous integration with Jenkins, and configuration management with Ansible. It details the goals and components of DevOps, installation and configuration of tools, and key commands and concepts for each technology. The document serves as a comprehensive guide for understanding and implementing DevOps methodologies and tools.

Uploaded by

prakasherg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit-1

INTRODUCTION TO DEVOPS​ ​ ​ ​ ​ ​ ​ 6
Devops Essentials - Introduction To AWS, GCP, Azure - Version control systems: Git and
Github.

DevOps Essentials

1. Introduction to DevOps

●​ DevOps is a set of practices that combines software development (Dev) and IT


operations (Ops) to improve collaboration, automation, and continuous delivery.
●​ Goals of DevOps:
○​ Faster software releases
○​ Improved collaboration between teams
○​ Automated infrastructure management
○​ Enhanced security and reliability

2. Key Components of DevOps

●​ CI/CD (Continuous Integration/Continuous Deployment): Automating the software


development lifecycle.
●​ Infrastructure as Code (IaC): Using code to manage IT infrastructure (e.g., Terraform,
Ansible).
●​ Monitoring & Logging: Tools like Prometheus, Grafana, ELK stack.
●​ Containerization: Using Docker and Kubernetes for deploying applications efficiently.

Introduction to Cloud Platforms

1. Amazon Web Services (AWS)

●​ Popular Services:
○​ Compute: EC2 (Virtual Machines), Lambda (Serverless Computing)
○​ Storage: S3 (Object Storage), EBS (Block Storage)
○​ Databases: RDS (Relational Database Service), DynamoDB (NoSQL)
○​ Networking: VPC, Route 53 (DNS), Load Balancer

2. Google Cloud Platform (GCP)

●​ Popular Services:
○​ Compute: Compute Engine (VMs), Cloud Functions (Serverless)
○​ Storage: Cloud Storage, Persistent Disks
○​ Databases: Cloud SQL (Managed SQL), Firestore (NoSQL)
○​ Networking: VPC, Cloud Load Balancing

3. Microsoft Azure

●​ Popular Services:
○​ Compute: Azure Virtual Machines, Azure Functions
○​ Storage: Blob Storage, Disk Storage
○​ Databases: Azure SQL Database, Cosmos DB (NoSQL)
○​ Networking: Azure Virtual Network, Load Balancer

Comparison of AWS, GCP, and Azure

Feature AWS GCP Azure

Compute EC2 Compute Engine Virtual Machines

Storage S3 Cloud Storage Blob Storage

Databases RDS, DynamoDB Cloud SQL, Firestore Azure SQL, Cosmos DB

Serverless Lambda Cloud Functions Azure Functions

Kubernete EKS GKE AKS


s

Version Control Systems: Git and GitHub

1. What is Git?

●​ A distributed version control system (DVCS) used for tracking code changes.
●​ Created by Linus Torvalds for Linux kernel development.

2. Basic Git Commands

●​ git init → Initialize a new Git repository.


●​ git clone <repo_url> → Clone an existing repository.
●​ git add <file> → Stage a file for commit.
●​ git commit -m "message" → Commit changes with a message.
●​ git status → Check the status of your working directory.
●​ git log → View commit history.
●​ git branch → List branches.
●​ git checkout <branch> → Switch to another branch.
●​ git merge <branch> → Merge a branch into the current branch.
●​ git pull → Fetch and merge changes from a remote repository.
●​ git push → Push changes to a remote repository.

3. What is GitHub?

●​ A cloud-based Git repository hosting service.


●​ Used for collaboration, issue tracking, and CI/CD integration.

4. Working with GitHub

●​ Create a repository (public or private).


●​ Push code to GitHub using git push.
●​ Fork repositories to contribute to open-source projects.
●​ Create pull requests to merge changes.
●​ Use GitHub Actions for CI/CD automation.

Unit-2

UNIT II COMPILE AND BUILD USING MAVEN & GRADLE 6

Introduction, Installation of Maven, POM files, Maven Build lifecycle, Build phases(compile build,
test,package) Maven Profiles, Maven repositories(local, central, global),Maven plugins, Maven
create and build Artificats, Dependency management, Installation of Gradle, Understand build
using Gradle.

Introduction to Maven

●​ Maven is a build automation and project management tool used for Java projects.
●​ It simplifies dependency management and project builds.
●​ Uses POM (Project Object Model) files for configuration.

1. Installation of Maven

Steps to Install Maven:

1.​ Download Apache Maven from Maven’s official site.


2.​ Extract the archive and set the MAVEN_HOME and PATH environment variables.

Verify installation using:​


sh​
CopyEdit​
mvn -version

3.​

2. POM (Project Object Model) Files

●​ [Link] is the configuration file of a Maven project.


●​ Defines project dependencies, build configurations, and plugins.

Basic Structure of [Link]:

xml

CopyEdit

<project xmlns="[Link]

<modelVersion>4.0.0</modelVersion>

<groupId>[Link]</groupId>

<artifactId>my-app</artifactId>

<version>1.0.0</version>

</project>

3. Maven Build Lifecycle

Maven defines three lifecycles:

1.​ Clean Lifecycle → Cleans previous build artifacts.


2.​ Default Lifecycle → Compiles, tests, and packages the code.
3.​ Site Lifecycle → Generates project documentation.

4. Build Phases in Maven


Maven's default lifecycle consists of several phases:

Phase Description

compi Compiles the source code.


le

test Runs unit tests using JUnit/TestNG.

packa Packages code into a JAR/WAR file.


ge

verif Runs integration tests.


y

insta Installs the package to the local


ll repository.

deplo Deploys the project to a remote


y repository.

Example Command:

sh

CopyEdit

mvn clean compile package


5. Maven Profiles

●​ Profiles allow different build configurations for development, testing, and


production.

Example Profile in [Link]:

xml

CopyEdit

<profiles>

<profile>

<id>dev</id>

<properties>

<env>development</env>

</properties>

</profile>

</profiles>

Activate it using:

sh

CopyEdit

mvn package -Pdev

6. Maven Repositories

Maven stores dependencies in three types of repositories:


1.​ Local Repository (~/.m2/repository) → Stores downloaded dependencies
locally.
2.​ Central Repository ([Link]) → Default repository for Maven
dependencies.
3.​ Remote/Global Repository → Custom repositories like JFrog Artifactory or Nexus.

7. Maven Plugins

Maven uses plugins to extend functionality.

●​ Build Plugins: Execute during the build process (e.g., maven-compiler-plugin).


●​ Reporting Plugins: Generate reports (e.g., maven-surefire-report-plugin).

Example: Maven Compiler Plugin

xml

CopyEdit

<build>

<plugins>

<plugin>

<groupId>[Link]</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.8.1</version>

<configuration>

<source>1.8</source>

<target>1.8</target>

</configuration>

</plugin>

</plugins>
</build>

8. Creating and Building Artifacts in Maven

●​ Artifacts are JAR/WAR files generated after building a project.

Use the following command to create and install an artifact:​


sh​
CopyEdit​
mvn clean package install

●​

9. Dependency Management in Maven

Maven manages dependencies via [Link].

Example Dependency (JUnit):

xml

CopyEdit

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.13.2</version>

<scope>test</scope>

</dependency>

</dependencies>
Scopes:

●​ compile → Default scope, required at compile time.


●​ test → Required for testing only.
●​ provided → Required for compile but not packaged.

Introduction to Gradle
●​ Gradle is a build automation tool similar to Maven but uses Groovy/Kotlin DSL
instead of XML.
●​ More flexible and faster than Maven due to incremental builds.

10. Installation of Gradle

Steps to Install Gradle:

1.​ Download from Gradle’s official site.


2.​ Set GRADLE_HOME and update the PATH variable.

Verify installation:​
sh​
CopyEdit​
gradle -v

3.​

11. Build Using Gradle

●​ Gradle uses a [Link] file for configuration.

Basic [Link] Example:

groovy

CopyEdit

plugins {

id 'java'
}

repositories {

mavenCentral()

dependencies {

testImplementation 'junit:junit:4.13.2'

Common Gradle Commands:

Command Description

gradle build Builds the project.

gradle clean Cleans previous builds.

gradle test Runs tests.

gradle Displays dependency


dependencies tree.

Key Differences: Maven vs. Gradle


Feature Maven Gradle

Language XML Groovy/Kotlin


([Link]) ([Link])

Performance Slower Faster (incremental builds)

Flexibility Less flexible Highly flexible

Dependency XML-based DSL-based


Management

UNIT III CONTINUOUS INTEGRATION USING JENKINS​ ​ ​ ​ ​ 6


Install & Configure Jenkins, Jenkins Architecture Overview, Creating a Jenkins Job, Configuring
a Jenkins job, Introduction to Plugins, Adding Plugins to Jenkins, Commonly used plugins (Git
Plugin, Parameter Plugin, HTML Publisher, Copy Artifact and Extended choice parameters).
Configuring Jenkins to work with java, Git and Maven, Creating a Jenkins Build and Jenkins
workspace.

Install & Configure Jenkins


Jenkins is an open-source automation server used for Continuous Integration (CI) and
Continuous Deployment (CD).

Installation Steps:

1.1 Installing Jenkins on Windows

1.​ Download Jenkins from: Jenkins official website


2.​ Install Java JDK (Jenkins requires Java 8 or later).
Run the Jenkins .war file using:​
sh​
CopyEdit​
java -jar [Link] --httpPort=8080

3.​
4.​ Access Jenkins in a browser: [Link]
5.​ Enter the initial administrator password (found in
C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword).
6.​ Install recommended plugins and create an admin user.

1.2 Installing Jenkins on Linux (Ubuntu)


Install Java:​
sh​
CopyEdit​
sudo apt update
sudo apt install openjdk-11-jdk

1.​

Add Jenkins repository and install Jenkins:​


sh​
CopyEdit​
wget -q -O - [Link] | sudo
apt-key add -
sudo sh -c 'echo deb [Link] binary/ >
/etc/apt/[Link].d/[Link]'
sudo apt update
sudo apt install jenkins

2.​

Start and enable Jenkins:​


sh​
CopyEdit​
sudo systemctl start jenkins
sudo systemctl enable jenkins

3.​
4.​ Access Jenkins in a browser at [Link]
2. Jenkins Architecture Overview
Jenkins follows a master-agent architecture:

●​ Master Node:
○​ Controls build execution.
○​ Manages the UI, scheduling, and plugins.
●​ Agent Node:
○​ Executes jobs as instructed by the master.
○​ Helps distribute workloads across machines.

Key Components of Jenkins

●​ Jenkins Dashboard: UI for managing jobs and configurations.


●​ Build Executor: Runs jobs on nodes.
●​ Workspaces: Stores job-specific files.
●​ Plugins: Extend Jenkins functionality (Git, Docker, Pipeline, etc.).

3. Creating a Jenkins Job


A Jenkins Job is a process that Jenkins runs.

Steps to Create a Job

1.​ Open Jenkins Dashboard → Click New Item.


2.​ Select Freestyle Project → Click OK.
3.​ Configure the Source Code Management (SCM):
○​ Select Git and enter repository URL.
4.​ Configure Build Triggers:
○​ Select Poll SCM or Build periodically.
5.​ Define Build Steps (Compile, Test, Deploy).
6.​ Click Save and Build Now to trigger the job.

4. Configuring a Jenkins Job


●​ Source Code Management (SCM) → Connects to GitHub/Git.
●​ Build Triggers → Defines when the job should run (e.g., after a commit).
●​ Build Environment → Defines parameters, scripts, and notifications.
●​ Post-Build Actions → Defines actions after build completion (e.g., email notification).
5. Introduction to Plugins
●​ Jenkins Plugins extend functionality (e.g., integrating with Git, Docker, etc.).
●​ Jenkins has over 1,500 plugins available in the Plugin Manager.

6. Adding Plugins to Jenkins


Steps to Install a Plugin

1.​ Go to Manage Jenkins → Manage Plugins.


2.​ Search for the plugin under Available Plugins.
3.​ Select Install without restart.
4.​ Restart Jenkins if required.

7. Commonly Used Plugins


Plugin Name Functionality

Git Plugin Integrates Jenkins with Git repositories.

Parameterized Plugin Allows user-defined parameters in


jobs.

HTML Publisher Plugin Publishes test reports and HTML files.

Copy Artifact Plugin Copies artifacts between jobs.

Extended Choice Allows advanced parameter options.


Plugin

7.1 Git Plugin Configuration

●​ Install Git Plugin from Jenkins Plugin Manager.

Configure Git in Jenkins:​


sh​
CopyEdit​
git config --global [Link] "YourName"
git config --global [Link] "you@[Link]"

●​
●​ Use the Git Repository URL in the job configuration.

7.2 Parameter Plugin Configuration

1.​ Go to Jenkins Job → Configure → Add Parameter.


2.​ Select String Parameter and define variables.
3.​ Run the job and provide parameter values.

8. Configuring Jenkins to Work with Java, Git, and Maven


8.1 Configuring Java

1.​ Install Java on the Jenkins server.


2.​ Configure Java in Jenkins:
○​ Go to Manage Jenkins → Global Tool Configuration → JDK.
○​ Add Java Home path.

8.2 Configuring Git

1.​ Install Git on the Jenkins server.


2.​ Configure Git in Global Tool Configuration.

8.3 Configuring Maven

1.​ Install Maven on the Jenkins server.


2.​ Configure Maven in Global Tool Configuration:
○​ Set Maven Home path.

9. Creating a Jenkins Build & Jenkins Workspace


9.1 Creating a Maven Build Job

1.​ New Item → Freestyle Project.


2.​ Source Code Management → Choose Git.
3.​ Build Steps → Select Invoke Maven Goals.
Enter goals:​
sh​
CopyEdit​
clean package

4.​
5.​ Save and click Build Now.

9.2 Understanding Jenkins Workspace

●​ Jenkins Workspace stores job-related files.

Located at:​
sh​
CopyEdit​
/var/lib/jenkins/workspace/

●​
●​ Each job has a separate folder inside workspace/.

10. Jenkins Build Triggers


Trigger Type Description

Manual Trigger Click Build Now in Jenkins UI.

SCM Polling Jenkins checks for Git changes.

Webhook Trigger GitHub webhook triggers build on push.

Scheduled Run builds at specific times (Cron jobs).


Builds

Example: Poll SCM Every 5 Minutes


sh
CopyEdit
H/5 * * * *

11. Jenkins Pipeline (Optional)


A Jenkins Pipeline automates the build process using a script.

Jenkinsfile Example (Declarative Pipeline)


groovy
CopyEdit
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git '[Link]
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Deploy') {
steps {
echo 'Deploying Application...'
}
}
}
}

●​ Save as Jenkinsfile in Git.


●​ Configure a Pipeline Job in Jenkins and select Pipeline script from SCM.
UNIT IV CONFIGURATION MANAGEMENT USING ANSIBLE ​ ​ ​ ​ 6
Ansible Introduction, Installation, Ansible master/slave configuration, YAML basics, Ansible
modules,Ansible Inventory files, Ansible playbooks, Ansible Roles, adhoc commands in ansible

Ansible Introduction
Ansible is an open-source configuration management, automation, and deployment tool.
It allows system administrators and DevOps engineers to automate tasks like:

●​ Software installation
●​ Configuration updates
●​ Application deployment
●​ Infrastructure provisioning

1.1 Features of Ansible

✅ Agentless: No need to install agents on remote machines.​


✅ Uses SSH: Secure and simple connection to nodes.​
✅ Declarative and Idempotent: Ensures desired state without repeated execution.​
✅ Scalable: Easily manages multiple servers.​
✅ Lightweight: Requires only Python on the target system.

2. Installation of Ansible
2.1 Installing Ansible on Linux (Ubuntu/Debian)
sh
CopyEdit
sudo apt update
sudo apt install ansible -y

Verify the installation:

sh
CopyEdit
ansible --version

2.2 Installing Ansible on RHEL/CentOS


sh
CopyEdit
sudo yum install epel-release -y
sudo yum install ansible -y

2.3 Installing Ansible on macOS


sh
CopyEdit
brew install ansible

3. Ansible Master/Slave Configuration


Ansible follows a master-slave architecture, where:

●​ Control Node (Master): Runs Ansible and sends commands.


●​ Managed Nodes (Slaves): Servers managed by Ansible using SSH.

Steps to Configure Master-Slave Setup


Ensure SSH access from Master to Slave:​
sh​
CopyEdit​
ssh-keygen -t rsa
ssh-copy-id user@slave-node

1.​

Verify connection from master node:​


sh​
CopyEdit​
ansible all -m ping

2.​

4. YAML Basics
Ansible uses YAML (Yet Another Markup Language) for configuration files.
Basic YAML Syntax

●​ Uses indentation for structure (no tabs, only spaces).


●​ Key-value pairs format.

Example YAML File ([Link]):

yaml
CopyEdit
name: John
age: 25
skills:
- DevOps
- Cloud Computing

5. Ansible Modules
Ansible modules are pre-built scripts that perform specific automation tasks.

Types of Modules
Module Type Example

System user, service,


package

Files copy, fetch, file

Network firewalld, ufw,


iptables

Cloud aws, gcp, azure_rm

Database mysql_db,
postgresql_db

Example: Using Ansible Modules


sh
CopyEdit
ansible all -m ping
ansible all -m shell -a "uptime"

6. Ansible Inventory Files


An inventory file contains the list of managed nodes.

Default Inventory File Location


bash
CopyEdit
/etc/ansible/hosts

Example Inventory File (hosts):


ini
CopyEdit
[web_servers]
server1 ansible_host=[Link] ansible_user=root
server2 ansible_host=[Link] ansible_user=root

[database_servers]
db1 ansible_host=[Link] ansible_user=root

Checking the Inventory


sh
CopyEdit
ansible-inventory --list -y

7. Ansible Playbooks
An Ansible Playbook is a set of automation tasks written in YAML.

Basic Playbook Example (install_apache.yaml):


yaml
CopyEdit
- name: Install Apache
hosts: web_servers
become: yes
tasks:
- name: Install Apache on Ubuntu
apt:
name: apache2
state: present

Running a Playbook
sh
CopyEdit
ansible-playbook install_apache.yaml

8. Ansible Roles
Roles allow you to structure large playbooks into reusable components.

Creating an Ansible Role


Generate a role structure:​
sh​
CopyEdit​
ansible-galaxy init myrole

1.​

Directory structure of a role:​


bash​
CopyEdit​
myrole/
├── tasks/[Link]
├── handlers/[Link]
├── templates/
├── files/
├── vars/[Link]
├── defaults/[Link]
├── meta/[Link]
├── tests/

2.​

Define tasks in tasks/[Link]:​


yaml​
CopyEdit​
- name: Install Nginx
apt:
name: nginx
state: present

3.​

Include the role in a playbook:​


yaml​
CopyEdit​
- hosts: web_servers
roles:
- myrole

4.​

Running the Role in Playbook


sh
CopyEdit
ansible-playbook [Link]

9. Ad-hoc Commands in Ansible


Ad-hoc commands run tasks directly without using a playbook.

Common Ad-hoc Commands


Command Description

ansible all -m ping Checks connectivity.

ansible all -m shell -a "df -h" Runs a shell


command.
ansible all -m package -a "name=nginx Installs Nginx.
state=present"

ansible all -m user -a "name=devops Creates a user.


state=present"

ansible all -m service -a "name=nginx Starts a service.


state=started"

UNIT V BUILDING DEVOPS PIPELINES USING AZURE​ ​ ​ ​ ​ 6


Create Github Account, Create Repository, Create Azure Organization, Create a new pipeline,
Build a sample code, Modify [Link] file

1. Introduction to Azure DevOps Pipelines


Azure DevOps Pipelines is a CI/CD (Continuous Integration and Continuous Deployment)
tool that helps automate software builds, tests, and deployments in Azure.

Key Features

✅ Automates code builds, testing, and deployments.​


✅ Supports multiple repositories (GitHub, Azure Repos, Bitbucket).​
✅ Uses YAML-based pipeline configuration.​
✅ Can be integrated with Docker, Kubernetes, and cloud services.

2. Creating a GitHub Account & Repository


2.1 Create a GitHub Account

1.​ Go to GitHub.
2.​ Click Sign Up and enter:
○​ Username
○​ Email
○​ Password
3.​ Verify your email and log in to GitHub.
2.2 Create a New Repository

1.​ Click on New Repository.


2.​ Enter a repository name (e.g., devops-pipeline).
3.​ Choose Public or Private.
4.​ Select Initialize with README.
5.​ Click Create Repository.

2.3 Clone Repository to Local Machine


sh
CopyEdit
git clone [Link]
cd devops-pipeline

3. Creating an Azure DevOps Organization


Steps to Create Azure Organization

1.​ Visit Azure DevOps and sign in.


2.​ Click New Organization.
3.​ Provide an Organization Name (e.g., my-devops-org).
4.​ Choose the Azure region closest to your location.
5.​ Click Continue.

Creating a New Azure DevOps Project

1.​ Inside your organization, click Create Project.


2.​ Enter a Project Name (e.g., DevOpsDemo).
3.​ Select Git as the Version Control System.
4.​ Click Create.

4. Creating a New Azure DevOps Pipeline


4.1 Steps to Create a Pipeline

1.​ Navigate to Azure DevOps → Your Project.


2.​ Click Pipelines in the left menu.
3.​ Click New Pipeline.
4.​ Choose GitHub as the source.
5.​ Select the repository (devops-pipeline).
6.​ Choose Starter Pipeline or Existing YAML file.
7.​ Click Save and Run.

5. Building a Sample Code in Azure Pipelines


5.1 Add a Sample Code to GitHub Repository

Create a sample Python file ([Link]):

python
CopyEdit
print("Hello, Azure DevOps!")

Create a unit test (test_app.py):

python
CopyEdit
import unittest
import app

class TestApp([Link]):
def test_output(self):
[Link]([Link](), "Hello, Azure DevOps!")

if __name__ == '__main__':
[Link]()

5.2 Create a Basic Azure Pipeline YAML File

Inside your GitHub repo, create .[Link]:

yaml
CopyEdit
trigger:
- main
pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'

- script: |
python -m pip install --upgrade pip
pip install pytest
displayName: 'Install Dependencies'

- script: |
pytest test_app.py
displayName: 'Run Tests'

6. Modifying [Link] File

6.1 Adding Build & Deployment Steps

Modify .[Link] to include build and deploy steps:

yaml
CopyEdit
trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'

- script: |
python -m pip install --upgrade pip
pip install pytest
displayName: 'Install Dependencies'

- script: |
pytest test_app.py
displayName: 'Run Tests'

- script: |
echo "Building the application..."
displayName: 'Build Application'

- script: |
echo "Deploying application..."
displayName: 'Deploy Application'

6.2 Committing and Pushing Changes to GitHub


sh
CopyEdit
git add .[Link]
git commit -m "Added Azure Pipelines config"
git push origin main

6.3 Running the Pipeline in Azure

1.​ Go to Azure DevOps → Pipelines.


2.​ Click on your pipeline and select Run.
3.​ Monitor logs to check if the build passes.

You might also like