ad hoc command
A single Ansible module run against a set of hosts straight from the command line, without writing a playbook.
In more detail
It has three parts: a host pattern, a module after -m, and the module's arguments after -a. Ad hoc commands suit questions and one-off recovery work while you watch the output. Anything you will need to repeat or explain later belongs in a playbook, because nothing about an ad hoc command is saved or reviewed.
Example
ansible all -m ansible.builtin.debug -a msg=helloRelated terms
- ansible command — The command-line tool that runs a single module against a host pattern, used for ad hoc commands and quick checks.
- host pattern — An expression that picks which hosts a command or play runs against, built from host names, group names and operators.
- Ansible module — A small program that knows how to manage one kind of thing, such as a file, a package or a service, and that a task calls to do its work.
- playbook — A YAML file containing one or more plays, which together describe the state Ansible should bring a set of hosts to.
Taught in
- Your First Ad Hoc Command — Ansible Configuration Management at Scale
- Twelve Green Panels: Dashboarding Basics — Prometheus Certified Associate (PCA) Exam Prep
- Forty Servers By Teatime: Ansible Playbooks, Inventories And Puppet Manifests — CompTIA Linux+ (XK0-006) Exam Prep
- A New Depot By Friday: OpenTofu, Cloud-init, Pipelines And Kubernetes — CompTIA Linux+ (XK0-006) Exam Prep
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- Inventory Variables: Ranges, group_vars And host_vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible.cfg: Which File Wins, And The Settings That Matter — RHCE in Ansible (EX294): Automate Red Hat Systems
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: A Web Node From A Ticket — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: Storage Only Where The Disk Exists — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 2: Real Machines And The Patterns That Fail — RHCE in Ansible (EX294): Automate Red Hat Systems