Day 59: Deploying a Simple Web App with Ansible ๐Ÿš€

ยท

2 min read

Day 59: Deploying a Simple Web App with Ansible ๐Ÿš€

Introduction: Welcome to Day 59 of our Ansible journey! After mastering Ansible playbooks, it's time to put our skills to the test with an exciting project. Today, we'll embark on the journey of deploying a simple web app using Ansible. Get ready to dive into the world of automation and witness the power of Ansible in action!

Task-01: Deploying a Simple Web App

Step 1: Create 3 EC2 Instances First, fire up three EC2 instances on AWS. Ensure that all instances are created with the same key pair for easy authentication.

Step 2: Install Ansible Next, let's install Ansible on our host server. Use the following commands to install Ansible:

sudo apt update

sudo apt install ansible

Step 3: Copy Private Key Now, copy the private key from your local machine to the host server (where Ansible is installed). Paste the private key into the .ssh directory of the host server, typically located at /home/ubuntu/.ssh.

Step 4: Access Inventory File Access the Ansible inventory file using a text editor like Vim:

sudo vim /etc/ansible/hosts

Here, define the IP addresses of your EC2 instances to include them in the Ansible inventory.

Step 5: Create a Playbook for Nginx Installation Create an Ansible playbook to install Nginx on your EC2 instances. Here's a sample playbook (nginx_install.yml):

--- - hosts: all become: yes tasks: - name: Install Nginx apt: name: nginx state: present

Step 6: Deploy Sample Web Page Now, let's deploy a sample web page using our Ansible playbook. Create another playbook (deploy_webpage.yml) to copy an HTML file to the Nginx web server directory (/var/www/html/):

--- - hosts: all become: yes tasks: - name: Copy Web Page copy: src: /path/to/sample.html dest: /var/www/html/

Execute the Playbook:

ansible-playbook deploy_webpage.yml

Conclusion: Congratulations! You've successfully deployed a simple web app using Ansible. This project showcases the power and simplicity of Ansible in automating infrastructure tasks. Stay tuned for more exciting adventures in our Ansible journey! ๐ŸŽ‰โœจ #Ansible #Automation #DevOps #WebDeployment #Project #LearningJourney ๐Ÿš€๐Ÿ”ง

Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.

You can connect with me at: https://www.linkedin.com/in/davendersingh/

ย