Ansible Ad-hoc Commands
Syntax
ansible host-pattern -m module [-a 'module arguments'] [-i inventory]
Example:
ansible all -m ping
# For sudo, use logname command to get the original username
ansible all -m ping -u $(logname)
To list the matching managed hosts without executing anything:
ansible --list-hosts