DevOps(Day-59): Ansible Project ๐Ÿ”ฅ

DevOps(Day-59): Ansible Project ๐Ÿ”ฅ

ยท

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.

ย