Conditions in ANSIBLE:

Screenshot (1145).png

Lab:

> Continue from Previous LAB of 4th Page

> Start all the Instances & login via PUTTY as we do if you stopped those instances after your previous lab

>Go to ANSIBLE-SERVER & do the below things:

ec2-user

sudo su

su - ansible

>Go to the all Connected NODES & do the below things:

ec2-user

sudo su

su - ansible

>Go to ANSIBLE-SERVER & do the below things:

vi conditions.yml

--- # CONDITIONAL PLAYBOOK
- hosts: demo
  user: ansible
  become: yes
  connection: ssh
  tasks: 
         - name: Install Apache Server for Debian Family
           command: apt-get -y install apache2
           when: ansible_os_family == "Debian"
         - name: Install Apache Server for RedHat Family
           command: yum -y install httpd
           when: ansible_os_family == "RedHat"

clear

>Go to the all Connected NODES & do the below things: