Deploy WebServer on AWS using Ansible

Statement : Deploy Web Server on AWS through ANSIBLE!

♦️ Provision EC2 instance through Ansible.

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

♦️ Configure the web server through Ansible!

♦️ Create role for web-server to customize the Instance and deploy the webpage to root directory.

Step: 1>

Install Boto module.

# pip3 install boto3

Step: 2>

Create IAM user own AWS.

AWS -> login -> Services -> Security Identity & Compliance -> IAM

Save the credentials obtained from here Access and Secret Key

Step: 3>

Create the workspace on system (I am using RHEL 8)

# mkdir ansible-task2

Also create YAML file for store configuration.

# vim os.yml

Step: 4>

Create a security vault to store the credentials obtained at Step: 2

# vim keys.yml

access_key: “<Your access key”
secret_key: “<Your Security key”

For extra security, we can encrypt this vault so no one can read the details in it.

To encrypt the vault,

# ansible-vault encrypt keys.yml

Then, if you try to read it using #cat keys.yml

Step: 5>

Now, add the .pem key of AWS in system.

I used WinSCP program for it.

Also enable the some special permissions to key

# chmod 600 <pem_file>

Step: 6>

Make some changes in configuration file of Ansible

# vim /etc/ansible/ansible.cfg

Step: 7>

Final Step:

Execute the Playbook

# ansible-playbook os.yml — ask-vault-pass

And, our web-server deployed !!

We can access the webpage using IP address given (Here:

Also we can check the instance created or not using manually visiting AWS Dashboard

Thanks for Reading :)

You can connect me on Linkedin:




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

Recommended from Medium

Why we dropped event sourcing with Kafka Streams when given a second chance

TIL-24: Hashing in Java — Part 2

zsh: command not found

Keeping constraints consistent across the stack

Making a pagination based infinite scroll as a beginner — on the backend.

jaeger-collector not working with ES_USERNAME and ES_PASSWORD

A Beginner’s Guide to Coding

ShardingSphere 4.x -Sharding-Sidercar

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
Prajwal Patil

Prajwal Patil

More from Medium

Replace Nginx reverse proxy with HTTP API Gateway by Terraform

Create an NGINX Docker Image and Register it on AWS ECR

AWS Elastic Network Interface

This Week I Learned: Mutual Human Authentication [2022–03–18]