Skip to content

KrMayank02/ConfigurationManagement_Ansible_Terraform

Repository files navigation

ConfigurationManagement_Ansible_Terraform

Objective: This Project automate the provisioning of infrastructure and configuring it with integration of Terraform and Ansible.

Real-time Scenario: Royal Hotel is a globally leading chain of hotels. Recently, as part of scaling up operations, they aim to automate every operation in the hotel. For this, multiple applications are onboarded within all the hotel’s main server. To keep these applications up and running and to scale them appropriately, they need fully managed virtual machines on AWS. They want to have an automated provisioned infrastructure through which they can create a new developer VM and manage some developer configurations on that server.


Major Tools Used in This Project:

  • Ansible: Ansible automates IT tasks, streamlining configuration management, application deployment, and orchestration. It uses simple, human-readable YAML files called playbooks.
  • Terraform: Terraform automates the provisioning and management of infrastructure using declarative configuration files. It supports multiple cloud providers and services, enabling consistent infrastructure deployment and scaling.

Supporting Package/Plugins/Server/Provider Resources used in Project:

  • AWS EC2 (Amazon Linux 2023): 5 VMs (5 EC2 Instances)
  • AWS VPC, Subnets, Route Table, Security Group, Key Pair
  • Java: java-21-amazon-corretto.x86_64 (as task of Ansible Playbook)
  • Apache Tomcat-9 Server (as task of Ansible Playbook)

High Level Project Diagram:

image

High Level Tasks/Steps:

  • Install Ansible and Terraform on Master machine of Linux distribution.
  • Create a directory as “terraform-multi-instances” and create these files: tomcat-playbook.yaml, ansible.cfg & terraform.tf
  • Run the terraform workflow and Ansible playbook commands in sequence.
  • Destroy/delete the provisioned resources in the AWS Cloud Infrastructure.

Output Result Screenshots:

Install Ansible and Terraform on Master machine of Linux distribution

image
image

Create an Ansible Playbook with name “tomcat-playbook.yaml” to define tasks for installing Java and then Tomcat-9 on 5 - EC2 Instances

image

Create Ansible Config file “ansible.cfg”

vi ansible.cfg

image

Create Terraform Configuration file “terraform.tf”

image
image
image
image

Run the terraform workflow commands in sequence:

  • terraform init
  • terraform validate
  • terraform plan
  • terraform apply -auto-approve
image
image
image
image
image

Now navigate to AWS Cloud Infrastructure to check newly provisioned Resources:

5 AWS EC2 Instances (5 VMs) created successfully – screenshot:

image

AWS VPC got created successfully with required CIDR, Subnet, Route table, Security group:

image
image
  • Playbook Task: Java-21 was installed on all 5 EC2 instances.
  • Playbook Task: Apache Tomcat-9 tar file was downloaded and extracted successfully.
image

Playbook Task: Tomcat-9 server was installed and started successfully on all the 5 VMs (5 EC2 Instances):

image

Now destroy/delete the provisioned resources in the AWS Cloud Infrastructure

  • terraform destroy -auto-approve

Command got executed successfully and all the terraform provisioned resources have been destroyed.


The above Project with all it's Steps, Files & Settings - automated the provisioning of infrastructure on AWS, to get fully managed Virtual Machines (multiple EC2 instances) and configuring each of the VMs to install multiple applications is met, with the integration of Terraform and Ansible.

About

This Project automates the provisioning of infrastructure on AWS using Terraform, to get fully managed multiple Virtual Machines (EC2 instances) and configuring each of the VMs to install multiple applications using Ansible.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages