🔅Create an ansible role myapache to configure Httpd WebServer.

🔅Create another ansible role myloadbalancer to configure HAProxy LB.

🔅We need to combine both of these roles controlling webserver versions
and solving challenge for host ip’s addition dynamically over each Managed
Node in HAProxy.cfg file.

What is ansible?

Ansible is an open source IT Configuration Management, Deployment & Orchestration tool. It aims to provide large productivity gains to a wide variety of automation challenges. This tool is very simple to use yet powerful enough to automate complex multi-tier IT application environments.

Ansible Terms:

  • Controller Machine: The machine where Ansible is installed, responsible for running the provisioning on the servers you are managing.
  • Inventory: An initialization file that contains information about the servers you are managing.
  • Playbook: The entry point for Ansible provisioning, where the automation is defined through tasks using YAML format.
  • Task: A block that defines a single procedure to be executed, e.g. Install a package.
  • Module: A module typically abstracts a system task, like dealing with packages or creating and changing files. Ansible has a multitude of built-in modules, but you can also create custom ones.
  • Role: A pre-defined way for organizing playbooks and other files in order to facilitate sharing and reusing portions of a provisioning.
  • Play: A provisioning executed from start to finish is called a play. In simple words, execution of a playbook is called a play.
  • Facts: Global variables containing information about the system, like network interfaces or operating system.
  • Handlers: Used to trigger service status changes, like restarting or stopping a service.

Ansible is a helpful tool that allows you to create groups of machines, describe how these machines should be configured or what actions should be taken on them. Ansible issues all commands from a central location to perform these tasks.

Today we are going to use Ansible Role’s:

To Perform this practical i have created two roles;

  • Myapache (To configure webserver)
  • Mylb ()

Command to create ansible roles are :

ansible-galaxy role init myapache

ansible-galaxy role init mylb

First go inside myapache 👇

Task 👇

Templates 👇

Vars 👇

Let’s go inside mylb 👇

Task 👇

Templates 👇

Now we have to set our roles path into the ansible configuration file.

vim /etc/ansible/ansible.cfg

Now come to final step:

To run our roles we have to create create a directory , inside it i have created a file setup.yml in which i created a playbook which will run my roles.

Directory 👇

Setup.yml 👇

https://www.linkedin.com/posts/swarnim-kashyap-b99405185_vimaldaga-righteducation-educationredefine-activity-6781506847561015296-tGEK

BY-SWARNIM KASHYAP

RedHat Certified Engineer| DevOps Enthusiast | Big Data Hadoop | RedHat Linux 8| AWS Cloud | GCP | Azure Cloud |GIT & GitHub |Python