Hi@akhtar,
You need to use the setup module to do this task. This module has the capability to gather information on remote nodes. You can use the below-given command to find the memory of remote nodes.
$ ansible server -m setup -a 'filter=ansible_*_mb'
192.168.0.180 | SUCCESS => {
"ansible_facts": {
"ansible_memfree_mb": 5723,
"ansible_memory_mb": {
"nocache": {
"free": 6711,
"used": 1262
},
"real": {
"free": 5723,
"total": 7973,
"used": 2250
},
"swap": {
"cached": 0,
"free": 8103,
"total": 8103,
"used": 0
}
},
"ansible_memtotal_mb": 7973,
"ansible_swapfree_mb": 8103,
"ansible_swaptotal_mb": 8103,
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false
}