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: 13.233.85.69)
Also we can check the instance created or not using manually visiting AWS Dashboard
Thanks for Reading :)
You can connect me on Linkedin: www.linkedin.com/in/prajwal-patil227