0% found this document useful (0 votes)
48 views45 pages

Deops Lab-1

The document outlines the CCS342 DevOps Laboratory course at Karpagam Institute of Technology, detailing course objectives, a list of experiments, and expected outcomes. It includes practical exercises such as creating Maven build pipelines, running regression tests, and installing Jenkins in the cloud. The document serves as a record of work done by students in the DevOps lab for the academic year 2023-2024.

Uploaded by

22ada20
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)
48 views45 pages

Deops Lab-1

The document outlines the CCS342 DevOps Laboratory course at Karpagam Institute of Technology, detailing course objectives, a list of experiments, and expected outcomes. It includes practical exercises such as creating Maven build pipelines, running regression tests, and installing Jenkins in the cloud. The document serves as a record of work done by students in the DevOps lab for the academic year 2023-2024.

Uploaded by

22ada20
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
You are on page 1/ 45

KARPAGAM INSTITUTE OF TECHNOLOGY

COIMBATORE - 641 105

CCS342 – DEVOPS LABORATORY

Name : ………………………………………………………

Reg.No : ………………………………………………………

Branch : ………………………………………………………

Year/Sem : ………………………………………………………
KARPAGAM INSTITUTE OF TECHNOLOGY
COIMBATORE - 641 105

DEPARTMENT
OF
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Certified that this is the bonafide record of work done

by………………………………………………… in the CCS342 DEVOPS LABORATORY of this

institution as prescribed by Anna University Chennai for the III/VI during the year 2023-2024.

Staff-in-charge Head of the Department

REGISTER NO : ………………………..

Submitted for the ……………………… Year / Semester Examination of the Institution

conducted on ……………………

Internal Examiner External Examiner


DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
CCS342 DEVOPS L P T C

COURSE OBJECTIVES:

• To introduce DevOps terminology, definition & concepts


• To understand the different Version control tools like Git, Mercurial
• To understand the concepts of Continuous Integration/ Continuous Testing/ Continuous
• Deployment)
• To understand Configuration management using Ansible 137
• Illustrate the benefits and drive the adoption of cloud-based Devops tools to solve real
world problems.

LIST OF EXPERIMENTS:

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. Use Metasploit to exploit an unpatched vulnerability
7. Build a simple application using Gradle
8. Install Ansible and configure ansible roles and to write playbooks

ADDITIONAL EXPERIMENT
9. Modify Azure – Pipelines .Yaml File

COURSE OUTCOMES:

CO1: Understand different actions performed through Version control tools like Git.
CO2: Perform Continuous Integration and Continuous Testing and Continuous Deployment using
Jenkins by building and automating test cases using Maven & Gradle.
CO3: Ability to Perform Automated Continuous Deployment
CO4: Ability to do configuration management using Ansible
CO5: Understand to leverage Cloud-based DevOps tools using Azure DevOps

PO’s PSO’s
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
1 3 3 3 2 3 - - - - - - - 2 2 2
2 3 3 3 2 3 - - - - - - - 2 2 2
3 3 3 3 2 3 - - - - - - - 2 2 2
4 3 3 3 2 3 - - - - - - - 2 2 2
5 3 3 3 2 3 - - - - - - - 2 2 2
AVG 3 3 3 2 3 - - - - - - - 2 2 2
INDEX

MARKS

S.NO DATE NAME OF THE PA


Practi Record Viva Total STAFF
EXPERIMENTS GE cal
(15) (10)
NO Assess (50) SIGNATURE
ment
(25 )

1. Create Maven Build pipeline 1


in Azure
2. Run regression tests using 6
Maven Build pipeline in
Azure
3. Install Jenkins in Cloud 10

4. Create CI pipeline using 14


Jenkins

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

6. Use Metasploit to exploit an 24


unpatched vulnerability

7. Build a simple application 27


using Gradle

8. Install Ansible and configure 33


ansible roles and to write
playbooks
ADDITIONAL EXPERIMENT

9. Modify Azure – Pipelines .Yaml 39


File
Ex. No: 1
CREATE A MAVEN BUILD PIPELINE IN AZURE
Date:

AIM:
To implement a Maven build pipeline to automate the build process of a Java application.

PROCEDURE:
Step 1: Open your web browser and navigate to Azure DevOps. Sign in with Azure DevOps
account.
Step 2: Create a New Project: Once logged in, click on "Projects" in the top left corner. Click
on the "New Project" button. Fill in the necessary details for your project (name,
description, visibility), and click "Create."

Step3: Setup Source Control: In your new project, navigate to the "Repos" Section. Import
or setup your Maven project in the source control system (e.g., Git).

Step 4: Create a New Build Pipeline: Navigate to the "Pipelines" section in your project. Click on

1
the "New pipeline" button. Choose your source repository (e.g.,GitHub,Azure Repos

Git).

Step 5: Select a Template: Azure DevOps will prompt you to choose a template. Search
for and select the "Maven" template.

Step 6: Configure the Pipeline: You'll be presented with a YAML editor for your pipeline.
Review and modify the YAML as needed. Make sure the pom.xml path is correctly specified.
The default is often $(System.Default Working Directory)/pom.xml. Customize Maven goals
and options if required.

Step 7: Build and Test: The default Maven task runs the clean install command. Adjust this
command if needed. Configure any additional Maven goals or options based on your project
requirements.

2
Step 8: Publish Artifacts (Optional): If your Maven build produces artifacts, Add a "Publish
Build Artifacts" task. Specify the path to the artifacts and choose where to publish them.

Step 9: Save and Queue: Save your pipeline configuration by clicking "Save" or "Save &
Queue." Optionally, queue a build to see it in action immediately.

3
Step10: Review Logs: Once the build is complete, review the logs to ensure that everything ran
successfully. Address any issues that may arise during the build process.
Step 11: Trigger Builds automatically (Optional): Configure triggers to automatically queue a build

whenever changes are pushed to the repository. Navigate to the "Triggers" tab in your
pipeline configuration to setup continuous integration.

Step 12: Setup Continuous Integration (Optional): Integrate your build pipeline with other
stages for continuous integration and delivery. Define deployment stages and tasks as
needed.

Step 13: Save and Run: Save your changes and run the pipeline to ensure that it functions as
expected. Monitor the pipeline for any errors or issues.

4
RESULT:

Thus, the setup of Maven Pipeline in Azure was built and implemented successfully.

5
Ex. No: 2
RUN REGRESSION TESTS USING MAVEN BUILD PIPELINE
Date:

AIM:
To implement a Maven build pipeline to automate the build process and run regression tests for a Java
application, ensuring that changes do not introduce new defects.

ALGORITHM:
Step 1: Initialize Maven: Set up the Maven environment for the project.
Step 2: Compile Code: Use Maven to compile the Java source code.
Step 3: Run Unit Tests: Execute unit tests using Maven Surefire Plugin.
Step 4: Run Regression Tests: Integrate regression tests into the build pipeline.
Step 5: Package Artifact: Package the application into a JAR or WAR file.

SOURCE CODE:
File 1: POM.xml

<!-- pom.xml -->


<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-java-app</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>

6
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<executions>
<execution>

<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.12</version>

<scope>test</scope>

</dependency>

7
</dependencies>
</build>
</project>

File 2: HelloWorld.java

public class HelloWorld {


public static String getHelloMessage()
{
return "Hello, World!";
}
public static void main(String[] args)
{
System.out.println(getHelloMessage());
}
}

File 3: HelloTest.java

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class HelloTest

@Test

public void testGetHelloMessage()

String expected = "Hello, World!";

String actual = Hello.getHelloMessage();

assertEquals(expected, actual);

8
RUN THE TEST:

mvn test

OUTPUT:

RESULT:
Thus, the code to build Maven pipeline was written and run the regression tests successfully.

9
Ex. No: 3
INSTALL JENKINS IN CLOUD
Date:

AIM:
To install and configure Jenkins on a cloud server to automate the build and deployment processes.

ALGORITHM:

Step 1: Choose any Cloud Provider such as AWS, GCP, Azure, etc.,
Step 2:Create an account in any one of the providers, consider AWS here for installing Jenkins.
Step 3: Create a key pair using Amazon EC2.
Step 4: Sign in to the AWS Management Console.
Step 5: Open the Amazon EC2 console by selecting EC2 under Compute.
Step 6: In the left-hand navigation bar, select Security Groups, and then select Create Security
group.

Step 7: In security group, select SSH, HTTP and create a group with specified IP address.
Step 8:To launch Amazon EC2 instance, follow the below steps:
Step 8.1: From the Amazon EC2 dashboard, select Launch Instance.

10
Step 8.2: The Choose an Amazon Machine Image (AMI) page displays a list of basic
configurations called Amazon Machine Images (AMIs) that serve as templates for your
instance. Select the HVM edition of the Amazon Linux AMI.

Step 8.3: Scroll down and select the key pair you created in the creating a key pair section
above or any existing key pair you intend to use.
• Select Select an existing security group.
• Select the WebServerSG security group that you created.
• Select Launch Instance.

11
Step 8.4: In the left-hand navigation bar, choose Instances to view the status of your
instance. Initially, the status of your instance is pending. After the status changes
to running, your instance is ready for use.

Step 9: To install and configure Jenkins follow the below steps:


Step 9.1: Select the instance and locate Public DNS.

Step 9.2: Connect to Linux instance Using PuTTy, by means of IP address of each
instance.
Step 10: Completing the previous steps enables us to download and install Jenkins on AWS. To

12
download and install Jenkins:
Step 10.1: Ensure that your software packages are up to date on your instance by using the
following command to perform a quick software update:
[ec2-user ~]$sudo yum update –y
Step 10.2: Add the Jenkins repo using the following command:
[ec2-user ~]$sudowget -O /etc/yum.repos.d/jenkins.repo\https://pkg.jenkins.io/redhat-
stable/jenkins.repo
Step 10.3: Import a key file from Jenkins-CI to enable installation from the package:
[ec2-user ~]$sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
[ec2-user ~]$sudo yum upgrade
Step10.4: Install Java (Amazon Linux 2023):
[ec2-user ~]$sudodnf install java-17-amazon-corretto -y
Step 10.5: Install Jenkins:
[ec2-user ~]$sudo yum install jenkins -y
Step 10.6: Enable the Jenkins service to start at boot:
[ec2-user ~]$sudosystemctl enable Jenkins
Step 10.7: Start Jenkins as a service:
[ec2-user ~]$sudosystemctl start jenkins

RESULT:
Thus, the steps to install Jenkins in cloud has been written and completed successfully.

13
Ex. No: 4
CREATE CI PIPELINE USING JENKINS
Date:

AIM:
To implement a Continuous Integration (CI) pipeline with Jenkins to automate the build and test
processes for a Java project.

PROCEDURE:
Step 1: Install the required Jenkins Plugins: Install the necessary plugins in Jenkins, such as Git,
Maven.
Step 2: Configure Jenkins Credentials: Set up credentials in Jenkins for accessing your version
control system.
Step 3: Create a New Jenkins Job: Open Jenkins and create a new freestyle project or a pipeline
job.
Step 4: Configure Source Code Management: Choose the version control system (e.g., Git).

Step 5: Provide the repository URL and credentials.

Step 6: Set Build Triggers: Configure triggers to initiate the build process automatically when

Changes are detected in the repository.

Step 7: Configure Build Steps: Define build steps based on your project requirements.

Step 8: Specify the Maven goals, such as clean install.

-mvn clean install

Step 9: Save and Run the Pipeline: Save the Jenkins job configuration.

Step 10: Manually trigger the job to ensure that it runs successfully.

Step 11: Integrate testing steps into the pipeline. For example, add additional Maven goals for

running unit tests.

-mvn clean test

Step 12: Customize the pipeline according to the specific needs of the build process.

14
Screenshot:

1. Create a New Jenkins Job:

• Open Jenkins and click on "New Item".


• Enter a name for the job and select the type (pipeline).

15
2.Set Build Triggers:

• Scroll down to the "Build Triggers" section.


• Select the option to trigger the build when changes are pushed to the repository.

3.Configure Pipeline Script:

• In the Pipeline Script add Pipeline Script to get executed.

16
4.Save and Run the Pipeline:
• Save the job configuration.
• Manually trigger the job and verify that the build process runs successfully.

17
18
OUTPUT:

RESULT:
Thus, creating a CI pipeline using Jenkins is executed and the output is verified successfully.

19
Ex. No: 5
CREATE A CD PIPELINE IN JENKINS AND DEPLOY IN CLOUD
Date:

AIM:
To implement a CD pipeline in Jenkins to automate the deployment of a Java application in AWS
cloud.

PROCEDURE:
Step 1: Launch Tomcat Server
• Enter the name “Tomcat-Server”
• Choose the Amazon Linux AMI.
• Select the size of the instance t3. micro or anything that lies in the free tier.
• Let's create a key pair for your instance, naming it 'Tomcat-Key' and download it.
• Choose “Tomcat-Security-Group”
Step 2: Connect to the Tomcat Server using SSH
Connect to it through SSH, following the same steps as followed in the Jenkins server by
clicking on “Connect”.
Step 3: Install Tomcat on your Instance
• Move to the opt directory and download the tomcat package
cd /opt
sudo wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.85/bin/apache-
tomcat-8.5.85.tar.gz.asc
• Now we have to unzip and untar the package with a single command, i.e.
sudo tar -xvzf apache-tomcat-8.5.85.tar.gz
• Move into the file "apache-tomcat-8.5.85.tar.gz"
• Now move to the bin folder
• Now the “startup.sh” is used for starting the tomcat server and “shutdown.sh” for
shutting down.
Step 4: Add tomcat credentials to Jenkins
• Go to Manage Jenkins>Manage Credentials
• Click on “global Credentials” and then “Add Credentials”
• We added a user with a role in tomcat
• Add the username and password as given and then create.

20
Step 5: Create a Job for deploying the Maven Project
• Click on “create a job”.
• Here is the GitHub Link to the project
• Fork the repo
• Enter a name for the project/job and select “maven project”
• In the Source Code Management, choose git and enter the repository URL, by
clicking on code
• Since all the code is in the master branch in the given project, we will use the
master branch.

• Under the build section, we usually give these three options, i.e., "clean install
package” with the pom.xml file already present there.
• pom.xml → It is an XML file that contains information about the project and
configuration details used by Maven to build the project
• Now choose the option “Deploy war/ear to a container”
• Next, we have to specify the path of the war file, or we can just write “**/*.war” so
that Jenkins will find the file having the type “.war” in that particular workspace.

• Now in the container section, choose tomcat with its latest version i.e., tomcat 9
• Also, choose the credentials from the dropdown that we just created, i.e., deployer
• Next, copy the URL of the tomcat server, on which you can access it from the
browser

21
• Now save and click on “Build Now”

22
• Now we can access our app on the browser by adding "/webapp" in the URL

• So whatever was written in the index.jsp will be visible here.

RESULT:
Thus, the process to implement a CD pipeline in Jenkins to automate the deployment of a Java
application in AWS cloud has been done successfully.

23
Ex. No: 6
CREATE AN ANSIBLE PLAYBOOK FOR A SIMPLE WEB
Date: APPLICATION INFRASTRUCTURE

AIM:
To develop an Ansible playbook for a simple web application.

PROCEDURE:
Step 1: First create two servers, a host machine for your Ansible and a server on which Ansible
will be performed.
Step 2: On the newly created servers, download package information from all configured
sources.
sudo apt-update
Step 3: Install Ansible on the host server
sudo apt install ansible
Step 4: Create your public and private keys which will be used to access the web server from the
Ansible host. on the terminal run the command and follow the prompt to generate the ssh
keys.
ssh-keygen
Step 5: Copy the content of the public key from the host server into .ssh/authorized_keys file on
the web server.
Step 6: Use the command ssh and try to ping the web server.
Step 7: Create an inventory file and add the private IP of the web server and ping using Ansible.
ansible -i inventory webserver -m ping
Step 8: Create a playbook. A playbook is a file used to run tasks with Ansible.The playbook
below shows the differnt tasks that were executed.
The tasks include:
1. create a group
2. create a user
3. create a file
4. create a webfolder
5. install apache2
6. start apache service

24
7. install unzip
8. decompress a fil
copy the file into /var/www/html
- hosts: webserver become: true
tasks:
- name: Create Group
group:
name: testadmin
gid: 401

- name: Create User


user:
name: test
state: present
uid: 400
group: testadmin
shell: /bin/bash

- name: Create file


file:
path: /opt/webconfig.conf
state: touch
owner: test
group: testadmin

- name: Create web folder


file:
path: /opt/webfiles
state: directory
owner: test
group: testadmin

- name: Install Apache2


apt:
name: apache2
state: present

- name: Start the apache2 service


service:
name: apache2
state: started
enabled: yes
- name: Install unzip
apt:
name: unzip
state: present

25
- name: Decompress the Downloaded file unarchive src:
https://github.com/inimitable/SwiggyClone/archive/refs/heads/master.zip

dest: /var/www/html
remote_src: true
- name: Copy downloaded content into /var/www/html
shell: |
cd /var/www/html && cp -r Swiggy-Clone-master/*/var/www/html/
Step 9: In the inventory file, paste the private ip address of your remote server.
[webserver]
ip address of your server
Step 10 : Run the ansible playbook
ansible-playbook -i inventory playbook.yaml
Step 11: Confirm the apache2 service is active and running
sudo systemctl status apache2.service
Step 12: Check the remote server to confirm that you have the folder in /var/www/html.
Step 13: Open your browser and type in the public ip of your server. We see a page similar to the
one below.

RESULT:

Thus, the sequential breakdown of the steps involved in creating an Ansible playbook for a simple
web application has been done and verified successfully.

26
Ex. No: 7
BUILD A SIMPLE APPLICATION USING GRADLE
Date:

AIM:
To build a simple Java application using Gradle.

PROCEDURE:

Step 1: Install Gradle

• Download and install Gradle.


• Set up the environment variables to include Gradle's bin directory.

Step 2: Initialize Gradle Project

• Open a terminal or command prompt.


• Create a new directory for your Gradle project:
mkdir MyGradleProject
cd MyGradleProject
• Run the following command to initialize a Gradle project:
gradle init --type java-application

Step 3: Project Structure

• Open the project folder in your preferred code editor or IDE.


• The project structure includes src/main/java for source code and src/test/java for tests.

Build Script (build.gradle)

• Edit the build.gradle file within the project directory.


• Define dependencies, configurations, and plugins.
For example:
plugins {
id 'java'
}
repositories {
mavenCentral()
}

27
dependencies {
implementation 'org. slf4j: slf4j-api:1.7.32'
testImplementation 'junit:junit:4.13.2'
}

Step 4: Write Code

• Create Java classes in the src/main/java directory.


• Write your application logic.

Step 5: Run the Application

• Use Gradle commands to build and run the application:


gradle build // To build the project
gradle run // To execute the application

Step 6: Testing (Optional)

• Create test classes in the src/test/java directory.


• Run tests using Gradle:
gradle test

Output:
1. Ensure Java is installed on your system

2. Download and unzip/unpack the compressed file. In File Explorer, create a new
directory C:\Gradle (you can choose any path according to your choice)

28
3. Configure your system environment, To set the Environment variable, Open System properties and
choose Environment Variables.

In the section System Variables select Path, then select the Edit option.

29
Select New, then add an entry for C:\Gradle\bin as shown in the image, now click on
the OK button to save changes.

4. Verifying and confirming the installation.

30
5. Gradle tasks can be written using Groovy code from inside a projects build.gradle file. These tasks
can then be executed using >gradle [taskname] at the terminal or by executing the task from within
an IDE such as Eclipse.

6. To create the Hello World example in gradle, define a task that will print a string to the console
using Groovy.

Source Code:
build.gradle
task helloWorld<< {

println ‘Hello world!’

}
7. To execute this task by using >gradle hello or >gradle -q hello. The -q is used to suppress gradle log
messages so that only the output of the task will be shown.

Output:

>gradle -q helloWorld

Hello world!

31
RESULT:
Thus, building a simple Hello World Application using Gradle has been done and verified
successfully.

32
Ex. No: 8
INSTALL ANSIBLE AND CONFIGURE ANSIBLE ROLES AND TO
Date: WRITE PLAYBOOKS

AIM:
To install Ansible & configure App server environment with roles.

PROCEDURE:
Step 1: Install Ansible.

sudo apt install ansible

Step 2: create the roles with following specs:

apache role which will

• Install httpd package

• configure httpd.conf

• Start httpd service

• Add a handler to restart service

Step 3: Create Ansible Roles.

Role Structure:

• Create a directory structure for roles:

mkdir -p ~/ansible/roles/your_role_name/{tasks,handlers,files,templates,vars,defaults,meta}

• Create Roles directory


mkdir roles
• Generate role scaffolding using ansible-galaxy.
ansible-galaxy init --offline --init-path=roles apache
• Validate
tree roles/

Output:
roles/

33
└── apache
├── defaults
│ └── main.yml
├── files
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── README.md
├── tasks
│ └── main.yml
├── templates
├── tests
│ ├── inventory
│ └── test.yml
└── vars
└── main.yml
• Create three different tasks files, one for each phase of application lifecycle * Install
* Configure * Start Service.
• To install apache, Create roles/apache/tasks/install.yml
---

- name: install apache web server


yum:
name: httpd
state: installed
To start the service, create roles/apache/tasks/service.yml with the following content
---
- name: start apache webserver
service:
name: httpd
state: started
enabled: true

34
• To have these tasks being called, include them into main task.

• Edit roles/apache/tasks/main.yml

---
# tasks file for apache
- import_tasks: install.yml
- import_tasks: service.yml
Create a playbook for app servers app.yml with following contents
---
- hosts: app
become: true
roles:
- apache

• Apply app.yml with ansible-playbook


ansible-playbook app.yml
OUTPUT:
PLAY [Playbook to configure App Servers]
*********************************************************************
TASK [setup]
*******************************************************************
ok: [192.168.61.12]
ok: [192.168.61.13]
TASK [apache : Install Apache...]
**********************************************
changed: [192.168.61.13]
changed: [192.168.61.12]
TASK [apache : Starting Apache...]
*********************************************
changed: [192.168.61.13]
changed: [192.168.61.12]
PLAY RECAP
*********************************************************************
192.168.61.12 : ok=3 changed=2 unreachable=0 failed=0

35
192.168.61.13 : ok=3 changed=2 unreachable=0 failed=0
• Copy index.html and httpd.conf from chap6/helper to /roles/apache/files/ directory
cd chap6
cp helper/httpd.conf roles/apache/files/
• Create a task file at roles/apache/tasks/config.yml to copy the configuration file.
---
- name: copy over httpd configs
copy:
src: httpd.conf
dest: /etc/httpd.conf
owner: root
group: root
mode: 0644
• Update this file to send a notification to restart service on configuration update. You simply have to
add the line which starts with notify

• Create the notification handler by updating roles/apache/handlers/main.yml

---

- name: copy over httpd configs

copy:

src: httpd.conf

dest: /etc/httpd.conf

owner: root

group: root

mode: 0644

notify: Restart apache service

---

- name: Restart apache service

36
service: name=httpd state=restarted

• Update tasks/main.yml to call the newly created tasks file.

---

- name: Restart apache service

service: name=httpd state=restarted

---

# tasks file for apache

- import_tasks: install.yml

- import_tasks: service.yml

- import_tasks: config.yml

• Apply and validate if the configuration file is being copied and service restarted.

ansible-playbook app.yml

RESULT:

Thus, the configuration to work with App server environment with roles was done and executed
successfully.

37
ADDITIONAL EXPERIMENT

38
Ex. No: 9
MODIFY AZURE – PIPELINES YAML FILE
Date:

AIM:
To modify pipeline .yaml file to check the CI/CD pipeline in Azure DevOps.

PROCEDURE:

Stage 1: Creation of Azure web app service


Step 1: Login to the Microsoft azure cloud portal. Log in using GitHub account also. Click on app-
services.
Step 2: Then select Create → Web App. The create web app page will appear. Enter the name of
the resource group of your choice. Then give any suitable web app name.
Step 3: Select the runtime stack as Java, as I have to deploy a Java based web application. The
tomcat container is used to run the Java application. Hence selected the Apache Tomcat
9.0.the operating system on which the web app is running in Linux.
Step 4: Now click on the Go to resource button. We will get the default domain name. Here the
domain name is given as noonewebapp.azurewebsites.net
Stage 2: Create azure pipeline using Azure DevOps
Step 1: Open the azure DevOps page and create a New Project. And give a suitable name to your
project.
Step 2: Click on repos, to select the exiting repository.
Step 3: Now click on pipelines and click on create Pipeline. Then select the repository. Then
configuration page appears. Select Maven Package Java Project Web app to Linux on
Azure.
Step 4: Select the subscriptions (free Trail) this is the subscription which you have selected on
your Azure cloud services.
Step 5: The yaml file named azure- pipelines.yml gets generate. Just edit the location of pom. xml
as My WebApp/pom.xml. Just click the Save and Run button.
Step 6: It will start working in two stages Build Stage and Deployment Stage.
Step 7: For the deployment stage, it will ask for permission. Just permit it by clicking on it and
then clicking on View button.

39
Step 8: Now, go to azure cloud and click on the URL to get the output.
Step 9: Just edit index.jsp in our repository of azure DevOps.

RESULT:
Thus, the modification for pipeline .yaml file has been done to check the CI/CD pipeline and
verified successfully.

40

You might also like