Posts

Ansible Roles (Httpd + Haproxy)

Image
 Today we will create 2 ansible roles and then will run them combined to create a load balancer setup with 2 nodes connected to it. Lets first init the roles by ansibe galaxy After these commads t15.yml is the main file in which we have combined both the codes Lets create tasks in both the roles httpdserver -> tasks -> main.yml The main.yml file in httpdserver Similarly for loadbalancer role loadbalancer  -> tasks -> main.yml The main.yml for loadbalancer The config file of haproxy looks like We can see the working of loadbalancer Thank You  for reading. I would like to thanks  Vimal Daga  Sir. ( https://www.linkedin.com/in/vimaldaga/ ) My Email — ayanchawlae@gmail.com My LinkedIn —   https://www.linkedin.com/in/ayanchawlae/

Ansible Playbook which will dynamically load the variable file named same as OS_name

Image
 Here, we will create 2 files RedHat.yml and Ubuntu.yml  Both will contain a variable called server and an ansible playbook will be created that will pick file accordingly the OS its been running and configure httpd if redhat and apache2 if it will be ubuntu. Here, os.yml is the main file that will pick other files depending on which it is been running This is the inventory file on which 137 is redhat and 135 is ubuntu Lets have a look at our playbook Files having server as a variable After running this file for ubuntu  For Redhat Thank You  for reading. I would like to thanks  Vimal Daga  Sir. ( https://www.linkedin.com/in/vimaldaga/ ) My Email — ayanchawlae@gmail.com My LinkedIn —   https://www.linkedin.com/in/ayanchawlae/

Dynamically pick the IP address of Docker container by Ansible

Image
 Today we will see how we can pick the dynamic IP of a docker container. First we will create a container by ansible and pull the centos image from docker hub. The complete playbook is  To run this playbook, use command ansible-playbook playbook_name After running it will prompt to ask the container name Lets see our docker service Now have a look at images Running containers We have to change the debug message to Output we get Lets check it by running inpect command of docker Thank You  for reading. I would like to thanks  Vimal Daga  Sir. ( https://www.linkedin.com/in/vimaldaga/ ) My Email — ayanchawlae@gmail.com My LinkedIn —   https://www.linkedin.com/in/ayanchawlae/

Use Ansible playbook to Configure Reverse Proxy

Image
 Today, We will configure reverse proxy server with ansible. In other words it is a system having load balancers and servers.  We have mainly 3 parts in this architecture  1. Controller Node 2. Load Balancers 3. Servers We will update our inventory file.  Here, Loadbalancer groups has all ips of load balancers and servers group has all servers ips. Lets have a look at our playbook.  After running this playbook. Our Servers are started Our Load Balancers config file.                                                                                                                                                ...

Ansible Handlers

Image
 In this post, you will learn about ansible handlers. Handlers are like if and else in ansible, suppose you have a configuration file in httpd server, and you want whenever you change something in configuration file, the httpd service must restart. In this case we will use handlers.  Components-: Controller node(192.168.1.7), Target node(192.168.1.8) The ansible-playbook looks like  It will only run the handlers portion only when notify will be changed. Target Node-  httpd is running on 8081. Playbook running when conf file is changed Playbook running second time You can view the webpage running on port 8081 Thank You  for reading. I would like to thanks  Vimal Daga  Sir. ( https://www.linkedin.com/in/vimaldaga/ ) My Email — ayanchawlae@gmail.com My LinkedIn —   https://www.linkedin.com/in/ayanchawlae/

Configure Hadoop and start cluster services using Ansible Playbook

Image
 Today, we will learn how to configure hadoop cluster using ansible. Setup: We need 3 machines - Ansible controller node(192.168.1.7), Hadoop Namenode(192.168.1.9), Hadoop Datanode(192.168.1.8) Steps: namenode install java  install hadoop create a directory  hdfs-site file config  <property> <name>dfs.data.dir</name> <value>/nn<value> </property> format directory with hadoop core-site file config <property> <name>fs.default.name</name> <value>hdfs://192.168.1.9:9001<value> </property> stop firewall start service slavenode install java  install hadoop create a directory hdfs-site file config <property> <name>dfs.data.dir</name> <value>/dn<value> </property> core-site file config <property> <name>fs.default.name</name> <value>hdfs://192.168.1.9:9001<value> </property> stop firewall start ser...

Ansible PlayBook to Configure Docker and Exposing the container to Launch a website

Image
Ansible - It is a tool to automate manual tasks. We have to write the code in a file called Ansible Playbook. We can 1 Control Node that controls all the Target/Host Nodes. Ip of my Control Node - 192.168.1.7 Ip of my Target Node - 192.168.1.5 Tasks -  Configure Docker Start and enable Docker services Pull the httpd server image from the Docker Hub Run the docker container and expose it to the public Copy the html code in /var/www/html directory and start the web server First, we will put the IP address of our target node in inventory file of control node and put the location of our inventory file in the .cfg file of ansible. Now we, will start writing our YAML file or ansible-playbook. Ansible has multiple modules to do the tasks. On the top we will write the  - hosts: all This is the syntax of YAML. Then below it, tasks: This tells that we have to perform following tasks. You must have configured Yum repo. Install Docker Start Docker Install Python2 and 36 as if needed Insta...