What is Ansible ?

  • It is an opensource automation tool
  • It is used to automate provisioning and orchestrate your infrastructure like creating servers(AWS,GCP,Linux systems etc), setting up the initial configuration on all those servers,deploying applications on the servers.
  • All manual things which is required to deploy an application the server can be automated using Ansible
  • You can make the Zero touch deployment using Ansible that means with one click everything is setup and deployed successfully

How Ansible Works

  • In simple terms, we just need one node as an Ansible Master node where you will install ansible software
  • There is no need to install any agent on any of the other nodes
  • It use the push mechanism to push the changes on to the remote nodes
  • SSH Setup is required to connect to all the remote hosts.

Why Ansible?

Problem Statement

  • There is a requirement of installing apache server on 10 nodes that requires creation of directories, user and groups.
  • You will download the software, extract it and do the initial configuration of that software and then restart the tomcat services so that access your application on the browser

Manual approach

  • You will login to each of the servers Create Users,groups,directories
  • Copy the software there and do the initial configuration

Issues

  • You need expert of doing all the above tasks Consume lot of time
  • Increases chances of having different configuration on servers
  • Manual Intervention

    Automated Approach

    • You will create an Ansible playbook which does all the above steps using yaml file.
    • Run the same playbook on all the servers which means there can’t be any surprised issues

        Prerequisite:

        1. Launch minimum 2 AWS EC2 instances
        2. Setup SSH connection between them

          Quick Setup

          • Set up your inventory file - you can use inventory as base
          • Adjust values on your group_vars/all.yml file
          • Run the lamp_setup.yml playbook to set up the LAMP server
          • Run the deploy_laravel.yml playbook to deploy the Laravel application
          • Access your server's IP address or hostname to test the setup