The ansible ad-hoc command with the -m or --module-name option can be used to gather facts. Facts are raw data about a system, such as the systems hostname and IP address. For example, here is how you would display your control node (that's your Ansible server) facts.
ansible localhost --module-name setup
Here is a snippet of some of the facts that should be returned.
"ansible_hostname": "server1" "ansible_all_ip4v_addresses": "10.1.2.3" "ansible_distribution": "CentOS"
Here is how you would display facts for every managed node in your default hosts file or your own inventory file.
ansible all --module-name setup
Or against a specific managed node.
ansible all --module-name setup --limit server1.example.com