Check host connection with Ansible

A command line for the basic use case when you need to check connection for all hosts in a specified inventory file:

ansible all --inventory INVENTORY_FILE --user REMOTE_USER --module-name ping

Short version:

ansible all -i INVENTORY_FILE -u REMOTE_USER -m ping

Drop --user if it present in the Ansible configuration file.

Example:

ansible all -i ./inventory/production -m ping

Sample output:

X.X.X.X | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
Y.Y.Y.Y | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

References:


ops

Somewhat related: