DevOps(Day-59): Ansible Project 🔥

Biswaraj SahooBiswaraj Sahoo
2 min read

TABLE OF CONTENTS

Ansible playbooks are amazing, as we learned yesterday. What if we deploy a simple web app using Ansible, sounds like a good project, right?

Task: Creating a Webpage through Ansible

  • Create 3 EC2 instances and make sure all three are created with the same key pair.

    1. Three servers are created that include Ansible master and node servers.

  • Install Ansible on the host server

    1. Create the ansible repository in the master server.

    2. Install Ansible through apt in the master server.

  • copy the private key from local to the Host server (Ansible_host) at (/home/ubuntu/.ssh)

    1. Copy the private key that you have created while creating the server.

    2. Create an ansible key file and store the above private key.

    3. Provide access permission for the key file.

  • access the inventory file using sudo vim /etc/ansible/hosts

    1. Create the inventory file in the master server to link the node servers to the master server.

  • Create a playbook to install Nginx

    1. Create a playbook to install, start and enable the Nginx in both the node servers.

    2. Execute the ansible-playbook yaml file to perform the task.

  • deploy a sample webpage using the ansible-playbook

    1. Create a webpage index.html file in the master server.

    2. Modify the ansible-playbook to transfer the index.html file to the Nginx location.

    3. Execute the ansible-playbook to execute the webpage.

    4. Login to the first node server to check the webpage.

Login to the second node server to check the webpage.

0
Subscribe to my newsletter

Read articles from Biswaraj Sahoo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Biswaraj Sahoo
Biswaraj Sahoo

--AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes Empowering communities via open source and education.