When automating or orchestrating tasks, Ansible is mainly used with playbooks to allow subtasks to be scripted and organized in a handy pipeline. However, Ansible also has various ad hoc commands. These allow the execution of a module on a host, or group of hosts, no matter how they are identified.
Once Ansible is installed, the ad hoc command line can be used directly. It can be easily tested, either by using it with the raw module or with some simple modules, such as ping or shell. As a quick example, each Ansible instance can ping itself using the following command:
ansible localhost -m ping
We should see the following output:
The -m option indicates the module name that will be used while the task is running.
Some could question the Ansible ad hoc commands usefulness. They are actually a great way to test your tasks in depth, thereby...