Basic Ad hoc commands on Ansible

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 ...

Get Ansible Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.