Executing multiple modules using the command line
As this chapter is all about modules and how to create them, let’s recap how to use modules. We’ve done this throughout this book, but we have not drawn attention to some of the specifics related to how they work. One of the key things we have not discussed is how the Ansible engine talks to its modules and vice versa, so let’s explore this now.
As ever, when working with Ansible commands, we need an inventory to run our commands against. For this chapter, as our focus is on the modules themselves, we will use a very simple and small inventory, as shown here:
[frontends] frt01.example.com [appservers] app01.example.com
Now, for the first part of our recap, you can run a module very easily via an ad hoc command and use the -m
switch to tell Ansible which module you want to run. Hence, one of the simplest commands you can run is the Ansible ping
command, as shown here:
$ ansible -i hosts appservers -m ping...