When any new variable about the system has been discovered it’s considered to be a “fact” in the playbook. Facts are mainly used to implement conditional executions. It can also be used to get ad-hoc information about the system.
You can get facts with the following command.
$ ansible all- m setup
So when you want to extract only a part of the information, you use the setup module to filter out only the needed information.