Rhce 03

If I have a requirement that whatever app I have created using playbook requires at least 4GiB RAM so if I run on a 16GiB RAM but it is occupied by some other program.

The system configuration is known by you as the controller node and the target node a made by you or any other IT guys so you which node contains how much CPU and how much RAM. what you don't know is the current state of the system. As on real time the utilization of the system keeps on changing.

what I want is that before I run the playbook I want to understand the real-time current utilization of the system and i write some conditions and condition is that if free ram <= 4GiB then I won't run playbook or task and then only I will deploy my app means whichever node satisfy this condition there your app is deployed.

There are much more conditions that we can set like we can set that this playbook or app will run on a system that contains more than 4 GB of RAM in Rhel version 9.1

Facts

Whenever the controller node hits the target node, ansible has the capability to retrieve the real-time status of the target node.

Any information that is retrieved and you want to use this data then you have to store in some variable or in some key. Technically this key or variable is known as facts about this node.

The command to retrieve all the facts of the node

ansible 3.110.51.91 –m setup

The “setup” module has the capability of retrieving all the real-time status of a node

When two systems exchange information they use a standard language called JSON

The different facts are grouped together in one block, this entire block of code has also been given a name ( here it is ansible_default_ipv4)

To retrieve a particular block of data, “filter” attribute can be used along with the information (fact) that is being retrieved. Here the information about the ansible_default_ipv4 of a node is retrieved

ansible 65.2.127.237 -m setup -a 'filter=ansible_default_ipv4'

we don't have to memorise the things if i know some keywords of that then it will be enough

like here I don't know the perfect keyword for memory but i know something that there is free b/w them then I use *.

now filter using playbook

we can also retrieve the information using dot (.)

in ansible for setting up the conditon or decision then we use when keyword

or

and when i set the variable to false then

now lets run the webserver using when keyword