Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

You need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?

BeginnerScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Ad-hoc fleet query.

What I'd do →

  1. If the fleet is in Ansible inventory: ansible all -m shell -a "df -hP" or a playbook with a filter; that is the fastest path.
  2. In Python, use Fabric's ThreadingGroup(*hosts).run("df -P", hide=True, warn=True) and parse output; collect failures separately.
  3. On AWS without SSH: SSM Run Command targeting by tag.
  4. Long term: node exporter plus an alert, so nobody has to ask.

Why → The right answer is often "this should be a metric, not a script".

Interview tip → End with the monitoring answer.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation