Prerequisite
Last updated by Nabeel Hassan
This Project is a Practice project for DevOps Beginners.
You will need following things for this Project:
- An IAM Role with AWS Administrator permissions: DevOps-EC2-Role
- A VPC with 10.0.0.0/16 CIDR: DevOps-VPC
- A IGW in VPC: DevOps-IGW
- A Public Subnet in VPC with CIDR 10.0.0.0/24: DevOps-Subnet-01
- A Key Pair for Devops EC2: DevOps-KP
- A Security allowing all access to myIp: DevOps-SG
- A EC2 in public Subnet with Elastic IP, IAM Role DevOps-EC2-Role and Security Group DevOps-SG on OS (Operating System) Ubuntu 22.04: DevOps-EC2.
- Install following tools in DevOps-EC2:
Use following scripts to install the tools.
Ansible
#!/bin/bash
set -euxo pipefail
apt update
apt upgrade -y
apt install -y software-properties-common python3 python3-pip
add-apt-repository --yes --update ppa:ansible/ansible
apt install -y ansible
ansible --versionAWS CLI
#!/bin/bash
apt-get update
apt install curl unzip -y
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
unzip -q /tmp/awscliv2.zip -d /tmp/
sudo /tmp/aws/installDocker
#!/bin/bash
apt-get update
apt-get upgrade -y
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do apt-get remove $pkg; done
# Add Docker's official GPG key:
apt-get update
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
# Installing Docker
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -yJenkins
#!/bin/bash
apt-get update
apt-get upgrade -y
wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
apt-get update
apt-get install fontconfig -y
apt-get install openjdk-17-jre -y
apt-get install jenkins -y
systemctl enable jenkins
systemctl start jenkinsTerraform
#!/bin/bash
apt update
apt upgrade -y
apt install -y gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
apt update
apt install terraform -y