Ansible & configuration management

Idempotent playbooks, inventories, roles, vault — and where config management still beats baking images. Push vs pull models in one mental model.

About 26 min read3-question knowledge check

The mental model

Ansible is a to-do list executor that connects to your servers over SSH and makes each item true. Not "run this script" — "ensure this end state." The item isn't "install nginx," it's "nginx is installed." If it already is, Ansible does nothing and reports ok; if it isn't, Ansible fixes it and reports changed. That property — run it twice, second run changes nothing — is idempotency, and it's the entire value proposition over shell scripts.

The analogy: a hotel housekeeping checklist. "Bed is made, towels are stocked (2 bath, 2 hand), minibar has 4 waters." The housekeeper doesn't remake a made bed. Running the checklist on a perfect room takes two minutes and changes nothing. A shell script, by contrast, is a set of actions — "make the bed" run twice can give you a weirdly double-made bed, or an error, unless you hand-write a guard for every step. Ansible modules build that state check in.

The second core idea: push vs pull. Ansible pushes — a control machine (your laptop, a CI runner) reaches out over SSH and applies the checklist right now. Nothing runs on the target except Python. Puppet and Chef classically pull — an agent on every node phones home every 30 minutes and converges itself. Push gives you orchestration and ordering ("drain the LB, then upgrade node 1, then node 2"); pull gives you continuous self-healing at fleet scale. Ansible won the mindshare war largely because "SSH + no agents" means the tool works on any box you can already log into.

Where does config management sit in the age of containers and baked images? Baking (Packer images, container images) wins for immutable app runtime. Config management still wins for: the hosts running the containers, long-lived stateful boxes (databases, GitLab runners, on-prem anything), network gear, and orchestrating procedures (rolling restarts, cert rotation) that aren't "an image" at all.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision