You are on page 1of 42

DEVOPS PROCESS AUTOMATION LAB

Worksheet -1.1
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd

Date of Performance:

Aim: Installation of Git and introduce them to some of the common Git commands.

Objective: To familiarize with the installation process of Git We are going to use
the following essential commands in Git.
a) git init f) git branch
b) git add g) git checkout
c) git commit h) git merge
d) git status i) git clone
e) git log j) git push

Installing Git on Windows:


• Download the Git installer for Windows from the official Git website:
https://git-scm.com/download/win

• Run the downloaded installer executable.


• Selecting the default options unless you have specific preferences.
• Choose the desired components and adjust the settings during the installation
process.

Verify Installation:
• Open the Command Prompt and type the following command. git --version
Here are explanations and examples of 10 common Git commands:

1. git init: Initializes a new Git repository in the current directory. Example:

2. git add: Stages changes for commit. It adds modified files to the staging area.
Example:

3. git commit: Creates a new commit with the changes that are staged in the
repository. Example:

4. git status: Displays the current status of your working directory and staging
area. Example:

5. git log: Shows a history of commits in the repository. Example:

6. git branch: Lists, creates, or deletes branches in the repository. Example:

7. git checkout: Switches between branches or commits, updating the working


directory.
Example:
2
8. git merge: Integrates changes from one branch into another. Example:

9. git clone: Creates a copy of a remote repository on your local machine.


Example:

10.git push: Uploads your local commits to a remote repository. Example:

Learning outcomes (What I have learnt):


• Installation of Git on Windows.
• Create and initialize Git repositories for projects.
• Perform commits to save project changes effectively.
• Use ‘git log’ to review commit history chronologically.
• Command essential Git operations for effective version control.

3
DEVOPS PROCESS AUTOMATION LAB
Worksheet -1.2
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3


Date of Performance:
Aim: The aim of this module is to introduce participants to the concept of visualizing
branches and adopting a branch naming convention in Git.

Objective: To understand the importance of visualizing branches, and


comprehend the benefits of a branch naming convention. We are going to use the
following essential commands in Git.
a) git branch d) git checkout
b) git merge e) git clone
c) git log f) git push

Here are commands for visualizing branches and adopting a branch naming convention:

1. git branch <branch name>: Creates branches in the repository.


Example:
2. git branch: Lists, creates, or deletes branches in the repository.
Example:

3. git checkout: Switches between branches or commits, updating the


working directory. Example:

4. git merge: Integrates changes from one branch into another. Example:

5. git clone: Creates a copy of a remote repository on your local


machine. Example:

6. git log: Shows a history of commits in the repository. Example:

7. git push: Uploads your local commits to a remote repository.


Example:
DEVOPS PROCESS AUTOMATION LAB
Worksheet -1.3
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: Installation and configuration of the JDK (Java Development Kit) and Apache Maven.

Objective: To familiarize with the installation and configuration process of JDK and Apache
Maven We are going to use the following essential steps.

1. Install JDK (Java Development Kit):


• The JDK provides tools, executables, and libraries necessary for Java development.
• Visit the Oracle JDK download page or the OpenJDK website.
• Choose the appropriate JDK version for your operating system (Windows, macOS, or
Linux).
• Download and run the installer.
• Follow the installer's instructions to complete the installation.

2. Set JAVA_HOME Environment Variable:


• After installing the JDK, it's important to set the ‘JAVA_HOME’ environment variable to
point to the JDK installation directory.

On Windows:
1
• Right-click on "This PC" or "Computer" and select "Properties."
• Click on "Advanced system settings" on the left.
• In the System Properties window, click the "Environment Variables" button.
• Under "System variables," click "New."
• Enter ‘JAVA_HOME’ as the variable name.
• Enter the path to your JDK installation directory (e.g., ‘C:\Program Files\Java\jdk-19’) as
the variable value.
• Click "OK" to save.

To install and configure Apache Maven on Windows system, follow these steps:

1. Download Apache Maven:


• Visit the official Apache Maven website: h
• Navigate to the "Download" section. ttps://maven.apache.org/

• Download the latest version of Apache Maven (a ‘.zip’ or ‘.tar.gz’ archive) from the
"Files" column.

2. Extract Maven:
• Locate the downloaded archive on your system and extract it to a directory of the
program file folder in C: drive. This directory will be referred to as the "Maven Home."

3. Set Environment Variables:


• Add Maven to your system's PATH environment variable to allow you to use Maven
from any command prompt or terminal window.

On Windows:
• Right-click on "This PC" and select "Properties."
• Click on "Advanced system settings" on the left.
• Click on the "Environment Variables" button.
• Under "System variables," find and select the "Path" variable, then click "Edit."
• Add a new entry with the path to your Maven bin directory (e.g., ‘C:\Program
Files\apache-maven-3.9.4-bin\apache-maven-3.9.4\bin’).

Adding a new Variable (System/User):

2
• To add a new variable, select either "System variables" or "User variables" (based on
your preference). • Click the "New" button.
• Enter the variable name in the "Variable name" field (e.g., ‘MAVEN_HOME’).
• Enter the variable value in the "Variable value" field (e.g., ‘C:\Program
Files\apachemaven-3.9.4-bin\apache-maven-3.9.4’).
• Click "OK" to close the dialog.
Verify your Maven installation by this command in the Command Prompt:

Example of creating a simple Java project using Maven commands and testing it:

1. Create a new Maven Project:


Open Command Prompt and create an example project using this command:

“mvn archetype:generate -DgroupId=com.example


-DartifactId=my-maven-project
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false”

2. Navigate to the project directory:

3
3. Clean and Build the Project:
The ‘clean’ goal removes the target directory containing compiled classes and artifacts from
previous builds. The ‘install’ goal compiles and packages your project.

4. Compile the Project:


If you only want to compile the project without packaging it:

5. Run Tests:
The ‘test’ goal runs the tests in the project.

Learning outcomes (What I have learnt):


• Installation of JDK and Apache Maven on Windows.
4
• Configure the ‘JAVA_HOME’ environment variable for resource accessibility.
• Utilize Apache Maven for efficient project management and builds.
• Integrate Maven's ‘bin’ directory into the system's ‘PATH’.
• Verify successful installations through version checks.

5
DEVOPS PROCESS AUTOMATION LAB
Worksheet -2.1
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: Write the steps and considerations to install Jenkins for software development projects and
should be kept in mind during the installation process.

Objective: To familiarize myself with the installation process of Jenkins Server. We are going
to use the following essential steps.

Step 1: Install Java


Jenkins is a Java-based application, so you'll need to install the Java Development Kit (JDK). You
can download and install OpenJDK or Oracle JDK.
• Download the JDK from the official Oracle website or the OpenJDK website.
https://www.oracle.com/java/technologies/javase-downloads.html.
• Run the JDK installer (‘.exe’ file) and follow the installation instructions to complete the
installation.

Step 2: Download Jenkins


1. Visit the Jenkins Download Page:
• Open a web browser and go to the Jenkins download page
at https://www.jenkins.io/download/.
2. Select Windows Installer:
1
• On the Jenkins download page, you'll see a section for Windows. Click on the "Windows" link
to download the Windows installer.

Step 3: Install Jenkins


1. Run the Jenkins Installer:
• Locate the downloaded Jenkins installer (‘.msi’ file) and double-click on it to run the installer.
2. Jenkins Setup Wizard:
• The Jenkins Setup Wizard will open. Follow these steps:
• Click "Next" to start the installation.
3. Choose Installation Directory:
• Choose the installation directory for Jenkins. The default directory is usually fine,
but you can change it if needed.
• Click "Next" to proceed.
4. Select Service Account:
• Choose the service account that Jenkins will run under. The default option is "Install as a
service," which is recommended. You can also choose "Run service as" and specify a
custom account if necessary.

• Click "Next" to continue.

5. Configure Port:
• Configure the port for Jenkins. The default port is 8080, but you can change it if needed.
6. Plugin Selection:
• Choose whether to install suggested plugins or select custom plugins. For most users,
installing the suggested plugins is a good choice.
• Click "Next" to proceed.
7. Create Admin User:

2
• Create an admin user for Jenkins and specify a password. Make sure to remember
this password, as you'll need it to unlock Jenkins.
• Click "Next" to continue.
8. Installation:
• Click "Install" to begin the installation.
9. Installation Complete:
• The installer will complete the installation, and you'll see a message indicating the success
of the installation.
• Click "Finish" to close the installer.
Step 4: Start Jenkins
• Jenkins will start automatically as a Windows service. There's no need to manually start it.

Step 5: Access Jenkins


• Open a web browser and go to ‘http://localhost:8080’ to access the Jenkins web interface.
• If you've installed Jenkins on a different machine, replace "localhost" with the hostname or
IP address of that machine.

Step 6: Unlock Jenkins


• In the web interface, you'll be prompted to enter the initial admin password. To find this
password, navigate to the location where Jenkins stores it, typically in a file called
"initialAdminPassword" in the Jenkins installation directory.

Step 7: Complete Setup


• Follow the on-screen instructions to complete the setup by creating an admin user and
installing recommended plugins.

Step 8: Start Using Jenkins


• Once the setup is complete, you can start using Jenkins to create and run jobs (builds and
pipelines).

3
Learning outcomes (What I have learnt):
• Learn about the installation of Jenkins on their systems.
• Understand the need for Java and install it.
• Learn about configuring Jenkins as a service.
• Learn to create an admin user during the initial setup.
• Learn about the installation and management of Jenkins plugins.

4
DEVOPS PROCESS AUTOMATION LAB
Worksheet -2.2
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: What are the key components and steps involved in setting up a delivery pipeline using
Jenkins for continuous integration and continuous delivery (CI/CD), and how can it be used to
automate and streamline the software development and deployment process?

Objective: To familiarize myself with the installation process of Jenkins Server. We are going
to use the following essential steps.

Key Components:

1. Source Code Repository (e.g., Git)


2. Jenkins Server
3. Build Environment
4. Build Jobs
5. Plugins
6. Deployment Environment
7. Testing and Quality Assurance Tools
8. Notification and Monitoring Tools

1
Step 1: Create a Jenkins Pipeline
1. Open the Jenkins web interface.
2. Click "New Item" to create a new Jenkins job.
3. Choose "Pipeline" and give it a name (e.g., "Node.js Pipeline").
4. Click "OK."

2
Step 2: Write the Jenkinsfile Script

Step 3: Save and Run the Pipeline


• Save the Jenkins Pipeline configuration.
• To run the pipeline, make code changes in your source code repository.

Step 4: Build Pipeline


• Click on Build Now button and wait for Build to Complete.
3
Step 5: Create a NodeJS file on the GitHub Repository

Step 5: Output

4
DEVOPS PROCESS AUTOMATION LAB
Worksheet -2.3
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20115

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: Write the steps involved in the scripted pipeline in a Jenkinsfile, and when should we
choose scripted over declarative for defining CI/CD pipelines in Jenkins?

Objective: To create a Jenkinsfile in our GitHub repository for build a CI/CD Pipeline in
Jenkins.

Step 1: Create a Jenkins Pipeline


1. Open the Jenkins web interface.
2. Click "New Item" to create a new Jenkins job.
3. Choose "Pipeline" and give it a name (e.g., "SCMpipeline").
4. Click "OK."

1
Step 2: Configure Your Pipeline in Jenkins:
• In the Jenkins web interface, create a new "Pipeline" job.
• In the job configuration, specify the location of your Jenkinsfile in your source
code repository.

Step 3: Save and Run the Pipeline


• Save the Jenkins Pipeline configuration.
• To run the pipeline, make code changes in your source code repository.

Step 4: Create a Jenkinsfile

2
• Create a Jenkinsfile in our repository.
• Click commit changes option for save this file.

Step 5: Build: Click on Build Now button.

Step 6: Create a NodeJS file on the GitHub Repository

Step 5: Output
3
4
DEVOPS PROCESS AUTOMATION LAB
Worksheet -3.1
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim:
a) Install and configure TeamCity Server.
b) Build a CI/CD pipeline in the TeamCity Server.

Objective: To familiarize myself with the installation process of TeamCity Server. We are
going to use the following essential steps and build a CI/CD pipeline with Maven.

a) Installation and Configuration Steps-

Step 1: Download TeamCity:


• Go to the TeamCity website (https://www.jetbrains.com/teamcity/download/) and download the
latest TeamCity distribution (Professional Free forever) for your operating system.
• Ensure that you have Java installed on your server. You can check this by running ‘java
version’ in your terminal or command prompt.

Step 2: Install TeamCity:


• Run the TeamCity installer executable.
• Follow the installation wizard, specifying the installation directory and other settings. •
Start the TeamCity server as a Windows service.
1
Step 3: Access Web Interface:
• Open a web browser and go to ‘localhost:8111’ to complete the initial configuration.
• Choose a data directory for configuration and artifacts.
• Provide a license if you have one or start with a free trial.
• Configure user accounts and permissions.

b) Pipeline Build Steps-

Step 1: Create a Project:


1. Open the TeamCity web interface.
2. Click "Projects" in the sidebar.
3. Create a new project and give it a name, such as "SampleJavaApp."

Step 2: Create a Build Configuration:


1. Within your project, click "Create Build Configuration."
2. Give the build configuration a name, e.g., "Build and Test."
3. Under "Version Control Settings," add your Git repository URL, and configure your VCS
settings.

2
Step 3: Set Up Build Steps:
1. In the build configuration settings, go to the "Build Steps" section.
2. Add a new build step with the following settings:
• Runner Type: Maven
• Step Name: Build and Test
• Goals: ‘clean install’ (This will clean, compile, run tests, and package your Maven
project)

3
• Maven version: Use the default version.

Step 5: Triggering Builds:


1. Configure a VCS trigger to start the build automatically when changes are pushed to the
repository.
2. Set up branch specification to define which branches should trigger builds.

Step 6: Save and Run:


1. Save your build configuration.
2. Click the "Run" button to test the pipeline manually. This will initiate a build of your
Java project.

4
Learning outcomes (What I have learnt):

5
DEVOPS PROCESS AUTOMATION LAB
Worksheet -3.2
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: Write the steps involved in Configuration Management using Puppet (AWS), mange the
complete process using EC2 install and Putty Terminal.

Objective: Successfully implement a new server configuration using Puppet in an AWS


environment to improve system management and automation.

Step 1: Set Up AWS Environment:


• Sign in to your AWS Management Console.
• Launch EC2 instances to serve as Puppet master and Puppet agent/slave. Make sure they are
in the same VPC and can communicate with each other.
• Note the public IP address or DNS names of these instances.
• Select AMI (Amazon Machine Image) for required to launch your instance.

1
Step 2: Configure Security Groups:
• Ensure that the security groups associated with your EC2 instances allow communication on
any other ports you intend to use for SSH, etc. Step 3: SSH Access and Key Pairs:
• Generate a key pair when launching your EC2 instances and download the “.ppk” private
key file.

2
Instances dashboard

Step 4: Connect to Puppet Master and Agents:


• Use PuTTY to connect to your Puppet master and Puppet agents using their public IP
addresses or DNS names. In PuTTY, use the “.ppk” private key file for authentication.

3
Step 5: Install and Configure Puppet Master:
• Update the package repository:
“sudo apt update”
• Download and Install the Puppet repository package:

• Install the Puppet master:

4
• Check the policy for Puppet master:

• Check the status of Puppet master service:

• Modify the Puppet master default configuration and add the following line in text editor:
“sudo vim /etc/default/puppet-master”

5
JAVA_ARGS=" -Xms512m -Xmx512m"

• Save and exit the text editor.


• Restart the Puppet master service
• Allow incoming traffic on port 8140 (Puppet master's port):

Step 6: Install and Configure Puppet Agent:


• Update the package repository: “sudo apt update”
• Download and Install the Puppet repository package:
“wget https://apt.puppetlabs.com/puppet-release-bionic.deb” “sudo dpkg
-i puppet-release-bionic.deb”

• Install the Puppet Agent:

6
• Edit the host file and add the following line:
“sudo nano /etc/hosts” and “MASTER_IP_ADDRESS puppet”

Step 7: Start Puppet Agent


• Start the puppet agent service.
• Enable the Puppet agent service to start on boot.

Step 8: Request Puppet Agent Certificate


• On the Puppet master, list pending certificate requests:
• Sign all pending certificate requests:

• Create the Manifests Directory:


• Edit the “site.pp” Manifest File:

• Puppet Resource Definition (site.pp content):

7
• Restart Puppet Master:
“sudo systemctl restart puppet-master”

Step 9: Puppet Agent contacts to Puppet Master


• Change Directory to /tmp: “cd /tmp”
• List Contents of /tmp Directory: “ls”
• Run Puppet Agent in Test Mode: “sudo puppet agent --test”
• Verify Puppet Manifest (Slave): “cat it_works.txt”

Learning outcomes (What I have learnt):


• Learn to install and configure Puppet on AWS EC2 instances running Ubuntu.
• Gain the ability to create Puppet manifests that define server configurations.
• Understand Puppet's certificate infrastructure for secure communication.

8
DEVOPS PROCESS AUTOMATION LAB
Worksheet -3.3
Subject code: 22CAP-745

Student Name: BIKI KUMAR RAI UID:22MCC20118

Section/Group: 22MCD-2/B Semester:3rd


Date of Performance:

Aim: Write the steps involved in Configuration Management using Chef (AWS), mange the
complete process using EC2 instance.

Objective: Automate configuration management on AWS using Chef on an Ubuntu EC2


instance, ensuring efficient deployment and maintenance of applications.

Step 1: AWS Account:


Ensure you have an AWS account and necessary permissions to create and manage EC2
instances.

1
Step 2: Install Chef Development Kit (Chef DK):
Download and install the Chef DK on your local machine. This includes tools like knife for
managing Chef resources.

Step 3: Create a Chef Repository


• Create a directory for your Chef repository on your local machine:
“mkdir chef-repo” and “cd chef-repo” “mkdir cookbooks”
and “cd cookbooks”
• Initialize the repository:

2
“chef generate cookbooks sample”

• Navigate to the newly created sample directory:


cd sample  cd recipes

Step 4: Write Chef Recipes:


• Write Chef recipes in the recipes directory to define how your EC2 instances should be
configured. Example: (sample/recipes/default.rb):

3
Step 5: Create a Chef Server
• Set up a Chef Server based on your requirements.
• Follow the installation instructions provided by Chef for your chosen Chef Server.

Step 6: Configure Knife


• Configure knife with your Chef Server details: “knife confiure” and “knife ssl check”

4
Step 7: Bootstrap EC2 Instances
• Launch EC2 instances in your AWS account using the AWS Management Console or AWS
CLI.

Step 8: Upload Cookbooks


• Upload your Chef recipes (cookbooks) to the Chef Server:

Step 9: Apply Configuration


• On the EC2 instance, run Chef to apply the configuration:

5
Step 10: Output

Learning outcomes (What I have learnt):

• Gain a clear understanding of Chef as a configuration management tool.


• Learn the principles of managing infrastructure as code for AWS.
• Understand how to upload and manage cookbooks on the Chef Server.
• Learn to apply and automate configurations, fostering continuous integration and
deployment practices.

You might also like