Ansible - ansible ad hoc setup command

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": ""
"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


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 85e93 in the box below so that we can be sure you are a human.