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 →
- 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. - In Python, use Fabric's
ThreadingGroup(*hosts).run("df -P", hide=True, warn=True)and parse output; collect failures separately. - On AWS without SSH: SSM Run Command targeting by tag.
- 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.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateA Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?IntermediateYou want to validate all Kubernetes manifests in a repo in CI with Python. What would the script check?Intermediate