Day 59: Ansible Project

Day 59: Ansible Project

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

Task-01

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

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

No alt text provided for this image
No alt text provided for this image

Add the Ansible PPA repository using the following command:

sudo apt-add-repository ppa:ansible/ansible        

Install Ansible using the following command:

sudo apt install ansible        

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

ansible --version        
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Copy the private key from local to Host server (ansible_host) at (/home/ubuntu/.ssh)

Copy private key from your local.

No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image

Create a playbook to install Nginx

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

Deploy a sample webpage using the ansible playbook

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

No alt text provided for this image

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


Run the playbook

No alt text provided for this image

Once the playbook finishes executing, open a web browser and enter the public IP address of one of the EC2 instances running Nginx

No alt text provided for this image
No alt text provided for this image


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

Anup D Ghattikar的更多文章

  • Django Rest Framework

    Django Rest Framework

    Introduction to Django Rest Framework Django REST framework (DRF) is a powerful and elegant toolkit built on top of the…

    11 条评论
  • Docker Tool Mastering

    Docker Tool Mastering

    What is Docker? Docker is a platform and toolset that simplifies the process of developing, deploying, and running…

    4 条评论
  • Devop's Bits & Byte's - By Anup Ghattikar

    Devop's Bits & Byte's - By Anup Ghattikar

    Medium Link: https://medium.com/@aghattikar82/devops-bits-bytes-by-anup-ghattikar-9a8c6b788ec9 HashNode Link:…

    10 条评论
  • Kubernetes Troubleshooting

    Kubernetes Troubleshooting

    Cluster Management Display endpoint information about the master and services in the cluster kubectl cluster-info…

    3 条评论
  • Kubernetes Cluster Maintenance

    Kubernetes Cluster Maintenance

    Kubernetes Cluster Upgrade Upgrade master Upgrading the control plane consist of the following steps: Upgrade kubeadm…

    2 条评论
  • Day 05:Kubernetes Storage Kubernetes Security

    Day 05:Kubernetes Storage Kubernetes Security

    Persistent Volumes Managing storage is a distinct problem from managing compute instances. The PersistentVolume…

  • Kubernetes services and service discovery

    Kubernetes services and service discovery

    Kubernetes is a powerful platform for deploying, scaling, and managing containerized applications. However, once you…

  • Day 03:Kubernetes Workloads

    Day 03:Kubernetes Workloads

    Kubernetes Deployment with YAML YAML (which stands for YAML Ain’t Markup Language) is a language used to provide…

    2 条评论
  • Kubernetes Networking

    Kubernetes Networking

    Topics Are: Services, Ingress, Network Policies, DNS, CNI Plugins Services Services provide a way to expose a set of…

    7 条评论
  • Day 70 - Terraform Modules

    Day 70 - Terraform Modules

    Modules are containers for multiple resources that are used together. A module consists of a collection of .

    2 条评论

社区洞察

其他会员也浏览了