Project : Capstone I
You have been hired as a Sr. DevOps Engineer in Abode Software. They want to implement DevOps Lifecycle in their company. You have been asked to implement this lifecycle as fast as possible. Abode Software is a product-based company and their product is available on this GitHub link. website.git
Following are the specifications of the lifecycle:
- Install the necessary software on the machines using a configuration management tool
- Git workflow has to be implemented
- CodeBuild should automatically be triggered once a commit is made to master branch or develop branch.
a.If a commit is made to master branch, test and push to prodb.If a commit is made to develop branch, just test the product, do not push to prod- The code should be containerized with the help of a Dockerfile. The Dockerfile should be built every time there is a push to GitHub. Use the following pre-built container for your application:
hshar/webappThe code should reside in/var/www/html- The above tasks should be defined in a Jenkins Pipeline with the following jobs:
a.Job1 : buildb.Job2 : testc.Job3 : prod
Provisioning Instances
I create three Ubuntu 22.04 EC2 instances, each located in a public subnet and configured to have a public IP enabled. This setup ensures that the instances are accessible and can handle network traffic effectively.
I name them:
Master
10.0.1.76Test10.0.1.51Prod10.0.1.218
Master
Installing Ansible
^aa5175
Assignment 1 – Ansible_Module 5_Devops BC = 2330070508
This is a more updated version than Assignment 1 – Ansible
%%Now we creates ssh key to be able to ssh into our salves following could not follow those steps cuse EC2 ssh doesnt use password%%
I generate the key by accepting the default options, simply pressing ‘Enter’ at each prompt.

I copy the contents of the public key
cat ~/.ssh/id_rsa.pubI’ll paste the contents of id_rsa.pub in the authorize_keys file belonging to the node we want ansible to connect to “Test” and “Prod”
sudo vi ~/.ssh/authorized_keysI add ‘Test’ and ‘Prod’ environments to my Ansible inventory.
%%forgot how to (the format) and looked at Assignment 1 – Ansible%%
[webservers]
Test ansible_host=10.0.1.51 ansible_user=ubuntu
Prod ansible_host=10.0.1.218 ansible_user=ubuntuQuestion
ansible -m pingfailFailure
Solution:
authorized_keyscan NOT have space
^061158
I verify the node connection once again.

I create playbook play.yaml
---
- name: Install Jenkins on Master
hosts: localhost
become: true
tasks:
- name: Install OpenJDK 17
apt:
name: openjdk-17-jdk
state: present
update_cache: true
- name: Add Jenkins repository key
apt_key:
url: https://pkg.jenkins.io/debian/jenkins.io-2023.key
state: present
- name: Add Jenkins repository
apt_repository:
repo: deb https://pkg.jenkins.io/debian binary/
state: present
update_cache: true
- name: Install Jenkins
apt:
name: jenkins
state: present
update_cache: true
- name: Install Docker.io, Java on Slave Nodes
hosts: all
become: true
tasks:
- name: Install OpenJDK 17
apt:
name: openjdk-17-jdk
state: present
update_cache: true
- name: Update apt cache
apt:
update_cache: yes
- name: Install docker.io
apt:
name: docker.io
state: present
- name: Ensure Docker service is running
systemd:
name: docker
state: started
enabled: yesBefore I check syntax

We successfully ran the command ansible-playbook play.yaml with 0 failures.

Verifying installations
master:
slaves:

%%the steps are really in Installing Jenkins On AWS %%
In addition to getting Jenkins ready, I add SSH credentials and configure agents, following the same steps from Assignment 1 – Jenkins.
%%Creating admin user
Creating credentials%%

%%adding agents%%

I’m using the HelloWorld_website repository, the same one used in Case Study 1 – Jenkins. This repository includes a Dockerfile and the website’s components, such as ‘index.html’ and image files.
Dockerfile
FROM ubuntu
RUN apt-get update
RUN apt-get install apache2 -y
ADD . /var/www/html
ENTRYPOINT apachectl -D FOREGROUNDInstall apache and hosts the page in Github
This Dockerfile creates a Docker image based on Ubuntu that installs and runs the Apache web server, serving the contents of HelloWorld_website from the /var/www/html directory within the container.

Job1
I have configured Job1 as a Freestyle Project. This job is designed to run in the “Test” environment using the “Develop” branch of the HelloWorld_website repository.

I insert the commands into “Execute shell” as I did in Case Study 1 – Jenkins

In the “Test” environment, I observe that within the workspace, Job1 is present, and additionally, there’s a container actively running.

I test this container by using the Public IP of the ‘Test’ server and directing traffic to port 83, which is mapped to the container.
Success
Job2
Job2 is configured as a Freestyle Project in the Jenkins setup. It is designed to run in the “Test” environment using the “main” branch.

Once again I check the “Test” environment, I observe that within the workspace, Job2 is present, and now there is a second container .

I test this container by using the Public IP of the ‘Test’ server and directing traffic this time to port 82, which is mapped to the container.
Success
Job 3
Job3 is configured as a Freestyle Project in the Jenkins setup. It is designed to run in the “Prod” environment using the “main” branch.



In the “Prod” environment, I observe that within the workspace, Job3 is present, and additionally, there’s a container actively running.

I test this container by using the Public IP of the “Prod” server and directing traffic this time to port 80 (default), which is mapped to the container.
Success




