Understanding ad hoc commands
We have already seen a handful of ad hoc commands so far in this book, but to recap, they are single tasks you can run with Ansible, making use of Ansible modules without the need to create or save playbooks. They are very useful for performing quick, one-off tasks on a number of remote machines or for testing and understanding the behavior of the Ansible modules that you intend to use in your playbooks. They are both a great learning tool and a quick and dirty (because you never document your work with a playbook) automation solution.
As with every Ansible example, we need an inventory to run against. Let’s reuse our production-inventory
file from before:
[frontends_na_zone] frontend1-na.example.com frontend2-na.example.com [frontends_emea_zone] frontend1-emea.example.com frontend2-emea.example.com [appservers_na_zone] appserver1-na.example.com appserver2-na.example.com [appservers_emea_zone] appserver1-emea.example.com appserver2-emea.example...