From the course: Red Hat Certified Engineer (EX294) Cert Prep: 1 Foundations of Ansible

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Introduction to ad-hoc commands

Introduction to ad-hoc commands

From the course: Red Hat Certified Engineer (EX294) Cert Prep: 1 Foundations of Ansible

Start my 1-month free trial

Introduction to ad-hoc commands

- An ad-hoc command uses the ansible command line tool to automate a single task on one or more managed nodes. You can not reuse them like playbooks. Whereas a playbook can be run multiple times to automate the configuration or orchestration of one or more nodes, an ad-hoc command is a one-time thing. Ad-hoc commands are for running tasks that you don't need to repeat. For instance, if you wanted to reboot all web servers, you wouldn't want to create a playbook just for this one task. It's easier to send an ad-hoc command to all web servers telling them to reboot. Also, the methods you use in an ad-hoc command can be used in a playbook. Sometimes it's useful to test a particular task before committing it to a playbook. Ad-hoc commands are perfect for this. You can also use any of the modules available for playbooks in ad-hoc commands. The syntax for an ad-hoc command is this. In this case, the pattern is a managed host…

Contents