From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Ad-hoc commands versus playbooks

Ad-hoc commands versus playbooks - Ansible Tutorial

From the course: Ansible: From Basics to Guru by Pearson

Ad-hoc commands versus playbooks

So, what are ad-hoc commands and why would you want to use them? That's because the best way to work with Ansible is by writing playbooks. Playbooks can define the desired state of your system. And they can consider complex dependency relations. And ad-hoc commands cannot do all of that. Ad-hoc command is just here and now and no dependencies at all. So you can use them for quick tasks that don't have dependencies and that don't need to be reproducible. Sometimes you just want to get something done, in an easy way, in a fast way. That's when you should have a look at ad-hoc commands. Ad-hoc commands also come in handy for testing. Now the basis of ad-hoc commands is the module. Ansible modules are provided to access a wide range of tasks. And the Ansible core package, which is always installed, provides a minimal amount of modules. Additional modules are installed using content collections. Modules are written in Python. And they are used in ad-hoc commands as well as in Ansible…

Contents