CONFIGURE WEB SERVER ON AWS BY USING ANSIBLE
Pre-requisites -
- Setup for Dynamic Inventory.
- Must have an AWS Cloud account.
- Install boto and ec2 package by pip command.
- Install ansible on the controller node.
- Set ansible configuration file like this -
Now let’s start the coding…
START HTTPD SERVICE:
Ec2.yml-
This file will launch an instance on the EC2 service.
Key.yml-
This file contains Access Key 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’ ”
Now change the mode of the key.
Now for securing the credentials use the vault command — “ ansible-vault create key.yml ”
The key file is secured.
For creating the instance run the ec2.yml file by using the command — “ ansible-playbook — ask-vault-pass ec2.yml ”
The instance is created.
List the hosts by using the command — “ ansible all — list-hosts ”
To check the connectivity first ping the instance by the command — “ ansible all -m ping ”
Now launch the configure web server by using the command — “ ansible-playbook file.yml ”
Access the webpage by using the public URL of the instance.
Thank you for reading my article!!
KEEP SHARING…KEEP GROWING…
Github Link — https://github.com/manali1230/Configure_Webserver_on_AWS.git