CONFIGURE WEB SERVER ON AWS BY USING ANSIBLE

Manali Jain
3 min readMar 18, 2021

--

Pre-requisites -

  1. Setup for Dynamic Inventory.
  2. Must have an AWS Cloud account.
  3. Install boto and ec2 package by pip command.
  4. Install ansible on the controller node.
  5. Set ansible configuration file like this -
Config file

Now let’s start the coding…

START HTTPD SERVICE:

Webserver Code

Ec2.yml-

This file will launch an instance on the EC2 service.

Instance Code

Key.yml-

This file contains Access Key and Secret Key.

Access and Secret key

— — — — — — — — — — — — — — — — — — — —

After writing code run the code by using the command.

First set the access key and secret key by using the command -

Access key — “ export AWS_ACCESS_KEY_ID=’XXXXXXXXXXXXX’ ”

Secret key — “ export AWS_SECRET_ACCESS_KEY=’xxxxxxxxxxxxxxxxxx’ ”

dynamic inventory file need access and secret key

Now change the mode of the key.

change the mode of key

Now for securing the credentials use the vault command — “ ansible-vault create key.yml ”

encrpt key

The key file is secured.

encrypted key

For creating the instance run the ec2.yml file by using the command — “ ansible-playbook — ask-vault-pass ec2.yml ”

launch instance

The instance is created.

instance running

List the hosts by using the command — “ ansible all — list-hosts ”

list hosts

To check the connectivity first ping the instance by the command — “ ansible all -m ping ”

check connectivity

Now launch the configure web server by using the command — “ ansible-playbook file.yml ”

Configure Webserver

Access the webpage by using the public URL of the instance.

webpage

Thank you for reading my article!!

KEEP SHARING…KEEP GROWING…

Github Link — https://github.com/manali1230/Configure_Webserver_on_AWS.git

--

--

Manali Jain
Manali Jain

Written by Manali Jain

You are the only one person who can Change Yourself…

No responses yet