Interview Prep/Ansible/Ad-hoc Commands, Modules and Idempotency

Give practical use cases for ad-hoc commands.

IntermediateConceptAd-hoc Commands, Modules and Idempotency
Answer
  • Check connectivity or uptime across the fleet.
  • Restart a service everywhere during an incident.
  • Check disk or memory quickly: ansible all -m shell -a "df -h /".
  • Push a hotfix file: ansible web -m copy -a "src=app.conf dest=/etc/app.conf" -b.
  • Gather facts of one host to inspect them: -m setup.
  • Install a package on a few hosts.

Because these are not recorded in version control, we reserve them for diagnostics and break-glass fixes and then codify real changes in a playbook.

All Ansible questions Roadmap: Ansible

More on Ad-hoc Commands, Modules and Idempotency