Ad-hoc commands in Ansible allow you to execute simple tasks at the command line against one or all of your hosts.
Syntax:-
ansible <hosts> [-m <module_name>] -a <"arguments"> -u <username> [--become]The list of all modules here:
https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html
The ping module: Try to connect to host, verify a usable python and return pong on success
root@:/etc/ansible# ansible all -m ping
ip address | SUCCESS => {
"changed": false,
"ping": "pong"
}
root@:/etc/ansible#ansible all -i ./hosts -m ping root@:/etc/ansible#ansible webservers -m ping 
Comments
Post a Comment