ansible

Run one-off Ansible tasks on remote hosts without a playbook.

medium risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

Ansible ad-hoc commands run single module tasks against inventory hosts without writing a playbook. Useful for quick checks, one-time changes, and testing connectivity. The -m flag selects the module; -a passes arguments.

Common flags
FlagMeaning
-m --module-nameAnsible module to run
-a --argsModule arguments
-i --inventoryInventory file or host list
-u --userRemote user
--becomeRun with privilege escalation (sudo)
-f --forksParallel processes (default: 5)
Examples
ansible webservers -i inventory.ini -m pingPing all webservers · explain & risk-check →
ansible all -m command -a 'uptime'Run uptime on all hosts · explain & risk-check →
ansible db -m service -a 'name=postgresql state=restarted' --becomeRestart PostgreSQL with sudo · explain & risk-check →
ansible all -m gather_facts -a 'filter=ansible_os_family'Gather OS family facts · explain & risk-check →
Pro tip

Use `ansible all -m ping -i inventory.ini` as a connectivity health check before running playbooks — catches SSH key issues and unreachable hosts before they cause partial failures.

Related
ssh scp
Open the full explainer →More in Terraform, Ansible & IaC

Reference text is hand-written and may be incomplete — check man ansible for your version. Test destructive commands on a non-production system first.