DevOps (Day: 59) Ansible Project

DevOps (Day: 59) Ansible Project

Dear Learners, In Today Article we will learn on the topic Ansible Project.

TABLE OF CONTENTS:-

Task: Creating a WebPage through Ansible.

Ansible Playooks are Amazing as you learned yesterday. What if you deploy a simple web application with the help of Ansible tool.

Task-01

Create an EC2 instance, make sure all the 3 instances are created with same key pair.

To create 3 EC2 instances, navigate to the EC2 service and launch them.

No alt text provided for this image
Create an EC2 instance, make sure all the 3 instances are created with same key pair Diagram.

After creating the 3 EC2 instances,designate one instance as the Ansible control node (Ansible_Master) and the other two instances as managed nodes( ansible_server).

No alt text provided for this image
To create 3 EC2 instances, navigate to the EC2 service and launch them Diagram.

Install the Ansible in master server.

Connect to your EC2 instance using SSH.

No alt text provided for this image
Connect to your EC2 instance using SSH Diagram.

Add the Ansible PPA repository using the following command.

sudo apt-add-repository ppa:ansible/ansible        
No alt text provided for this image
Add the Ansible PPA repository using the following command Diagram.

Update the Package using the following commands.

sudo apt update -y         

Install the Ansible using the following command:

sudo apt install ansible -y         
No alt text provided for this image
Update the Package using the following commands /Install the Ansible using the following command Diagram.

Once the installation is done is complete,you can check the version of Ansible using the following command:

ansible --version        
No alt text provided for this image
check the version of Ansible using the following command Diagram.

Copy the private key form the local to host server (ansible_server) at (/home/ubuntu/.ssh)

Copy the private form the local.

No alt text provided for this image
Copy the private form the local Diagram.

To proceed with the setup,copy the private key to the Ansible Control node (ansible_master) by creating a new file at /home/ubuntu/.ssh and pasting the private key in that file.

No alt text provided for this image
creating a new file at /home/ubuntu/.ssh and pasting the private key in that file Diagram.

Give permissions to the private key using file using chmod command.

No alt text provided for this image
Give permissions to the private key using file using chmod diagram.

Access the inventory file using sudo nano /etc/ansible/hosts

Create inventory file at location /etc/ansible/hosts which is by default location of file. Ansible hosts file is a configuration file that contains a list of hosts or servers. Add the IP addresses of the servers also add private key file location to use for authentication are highlighted in the white colour.

No alt text provided for this image
Access the inventory file using sudo nano /etc/ansible/hosts Diagram

Create a Playbook to install the Nginx.

If you need the ansible playbook syntax you can direct copy form these link, It will be helpful and save your time.

https://theraloss.com/how-to-configure-nginx-using-ansible-on-ubuntu/

No alt text provided for this image
Create a Playbook to install the Nginx Diagram.

In this playbook, we firstly specify the name of the playbook (install the Nginx) and the hosts we want to target(servers). We also set become yes to run the tasks with the root priviligies.

First task updates the apt cache on the manages nodes using the apt module. The second task installs the latest version of the Nginx using the same module. The third task uses service module to start the nginx service by specfying the service name (nginx) and setting the state parmeter. to started.

Now let's discuss the how to run Playbook using the ansible-playbook command.

ansible-playbook file-name.yml        
No alt text provided for this image
ansible-playbook file-name.yml Diagram.

To check the Status of Nginx on the 2 EC2 instances Highlight in the colour.

No alt text provided for this image
To check the Status of Nginx on the 2 EC2 instances Highlight in the colour Diagram

Now Deploy a sample webpage using the ansible playbooks.

Create a new file index.html in the playbook directory, and add some sample content.

No alt text provided for this image
Create a new file index.html in the playbook directory, and add some sample content Diagram.

Update a ansible playbook file, install_nginx.yml in the playbook directory.

No alt text provided for this image
Update a ansible playbook file, install_nginx.yml in the playbook directory. Diagram.

This playbook will copy the index.html file to the defuslt Nginx web server document root directory at /var/www/html/.

Run the Playbooks.

No alt text provided for this image
This playbook will copy the index.html file to the defuslt Nginx web server document root directory at /var/www/html/ Diagram.

Once the Playbook finishe executing,open a web browser and enter the public IP Address of one of the EC2 instance running Nginx.

Testing of the Server1:

Testing of the Server2:

No alt text provided for this image
Testing of the Server1 Testing of the Server2:

Hope I helped you in understanding the concept in a better way!!

Happy Learning!!


Next Topic:

Day 60: Terraform Infrastructure as a code.




shubhlaxmi shukla

CKA certified | REDHAT OPENSTACK Certified |GCP-Associate cloud engineer certified| Docker | kubernetes | AzureDevOps | AWS | Linux | ansible | cicd | jenkins | terraform | Grafana | GIT |GITHUB

1 年

well done!!keep it up

Abhishek Yadav

RHCSA | RHCE | AWS | ANSIBLE | LINUX | Git | Docker | MySQL | JENKINS | KUBERNETES | TERRAFORM

1 年

Beautiful described ??

Maninder Singh

AWS || Networking || Docker || Mentor & Tutor || System Engineer Antier Solution

1 年

++

回复

要查看或添加评论,请登录

Maninder Singh的更多文章

  • Artificial Intelligence for DevOps Engineer

    Artificial Intelligence for DevOps Engineer

    Dear learners, In today article we will explain the Artificial Intelligence for the DevOps Engineers. Important Aspects…

    12 条评论
  • Bash Shell Scripting:- Lesson 7,8 &9 for DevOps Engineers.

    Bash Shell Scripting:- Lesson 7,8 &9 for DevOps Engineers.

    Dear Learners, In Today Topic, We will learn the Shell Scripting form Basics to Advanced for DevOps Engineers. Course…

    3 条评论
  • Bash Shell Scripting:- Lesson 4,5 &6 for DevOps Engineers.

    Bash Shell Scripting:- Lesson 4,5 &6 for DevOps Engineers.

    Dear Learners, In Today Topic, We will learn the Shell Scripting form Basics to Advanced for DevOps Engineers. Course…

    3 条评论
  • Bash Shell Scripting:- Lesson 1,2 &3 for DevOps Engineers.

    Bash Shell Scripting:- Lesson 1,2 &3 for DevOps Engineers.

    Dear Learners, In Today Topic, We will learn the Shell Scripting form Basics to Advanced for DevOps Engineers. Course…

    3 条评论
  • EP 2 DevOps:- 2 Tier Application Deployment

    EP 2 DevOps:- 2 Tier Application Deployment

    2-Tier Application Deployment Diagram (Architecture) Dear Learners in today topic we will deploy a 2 Tier Application…

    8 条评论
  • DevOps Engineers:- Docker Cheat Sheet

    DevOps Engineers:- Docker Cheat Sheet

    Dear learner, presented below is a concise yet comprehensive Docker cheat sheet, complete with detailed commands and…

    7 条评论
  • DevOps (Day-90): Ending the challengs

    DevOps (Day-90): Ending the challengs

    Table of Contents: Flashback Self-Impact of Learning Today, We have completed the 90days of DevOps challenge where we…

    16 条评论
  • DevOps (Day-88): Kubernetes Architecture

    DevOps (Day-88): Kubernetes Architecture

    Dear Learner's in today topic we will discuss the Kubernetes Architecture in detail. Table of Contents Kubernetes…

    1 条评论
  • DevOps (Day-87): Argo CD

    DevOps (Day-87): Argo CD

    Dear Learners in today topic we will the discuss the Argo CD in Kubernetes. Table of Contents Challenges with CD into…

    13 条评论
  • DevOps (Day-86): Project-7 Portfolio App

    DevOps (Day-86): Project-7 Portfolio App

    Dear Learners in Today's article we will deploying a Portfolio app on AWS S3 Bucket using GitHub. Table of Contents:…

    10 条评论

社区洞察

其他会员也浏览了