TASK2_RH294_ANSIBLE_DEPLOY_WEBSERVER_ON_AWS_USING_DYNAMIC_INVENTORY

TASK DESCRIPTION:-

♦️Provision EC2 instance through ansible.

♦️Retrieve the IP Address of instance using dynamic inventory concept.

♦️Configure the web server through ansible!

♦️Create role for webserver to customize the Instance and deploy the webpage to root directory.

To perform this task we first create different roles and defined them in the ansible configuration files. Also we have to use the privilege_escalation block to give ec2-user root access.

After this we have created two different roles. One is for launching an ec2 instance on aws cloud using the localhost.

After this the python code will retrieve the Public ip of the launched ec2 instance and with the use of this retrieved ip we can use a dynamic inventory and with its use we can install the httpd package in it.

Here i have showed the roles folder and the code to create a new role.

In the ec2oslaunch role I have multiple files. One file is used to store multiple tasks. And the variable file is encrypted using the ansible-vault command as this file will contain the credentials of my aws account.

This role is used to run the commands on the localhost as it will use the localhost to connect to the aws cloud and launch instances their. We can change the no of instances by changing the count variable value.

I have created a separate folder for running the ansible-playbook. For running the playbook we need to use some special keywords as the variable files are encrypted.

After launching the ec2 instance we can confirm it from the webui and also by logging in we can check that whether the httpd software is installed or not.

Now we have to we can use the ec2.py code to retrieve the public ip of the instance also we need to put the ec2.py file in the ansible_inventory folder.

I have created one more role for installing the httpd package in the ec2 instance using the dynamic inventory.

We can run the apacheconfig playbook to install the package here.

We can check whether the package is installed or not by directly logging into the ec2 instance.

Github URL:- https://github.com/akshat-crypto/RH294_task2.git

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Leveraging Postman Collections for Offensive Webapp Testing

Kubeflow Pipelines with GPUs

Docker Containers and Images

Check out Gear’s August updates

How To Create Custom CI/CD With Github and Docker

Android Based Edge Computing Gateway for WSO2 IoT Server : Overview

Running Charles over VPN connection for iOS simulator or iPhone

Cloud Transformation in 2020 and Beyond

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akshat Soni

Akshat Soni

More from Medium

Bifurcation One: chapter four

What is Success?

<a href=””>”Charity” Hospital</a>

Random Thoughts on Obi-Wan Kenobi from Jacob Schoeneberger Part 1