Ad hoc commands in Ansible are used to perform tasks or operations that are needed on an ad hoc basis, or only once, based upon the requirement. In other words, these are tasks that a user wants to be performed on the fly but doesn't want to be saved for later use. A quick example of a use case for Ansible ad hoc commands could be to fetch the version information of the group of managed nodes for some other use as a one-time task. As this is a quick information need and does not need to be repeated, we would use an ad hoc task to perform this request.
As we proceed with the chapter, there will be some additional switches (extra options that we pass to Ansible commands), which will be introduced based upon the requirements. Invoking ansible as a standalone command, will display all the values that can be passed as options or parameters:
Some...