WEB1nginxoffport80CONFIG TOOLWEB2nginx—port—WEB3nginxonport801want = {"nginx": "on", "port": 80}2def apply(have):3 diff = dict(want.items() - have.items())4 have.update(diff)5 return diffBY HAND
Green blocks: servers, with their two settings on topBlue: the config tool and its lanes · front: the tool in PythonEnvelopes: facts in, fixes outConfiguration management: the desired state is written once, and a tool makes every server match it. Each run reads what the servers have (facts), works out the difference, changes only that and reports it; a second run changes nothing (idempotent). When web3 is edited by hand (drift), the next run puts it back. The figure shrinks each server to two settings. Real tools manage packages, files, users and services, and each one has its own check (is it installed? is the file the same?), but the idea is the same: compare, then change only what differs.

The idea

  1. Configuration management means writing down how every server should be set up, then letting a tool make each one match. No one logs in to change servers by hand, so they all stay the same.

One run: read, compare, change

Run it again, and drift

Two ways to run

What happens

;; step 1/9 · idea
desired state (written once, in a file)
        ↓ a tool applies it
web1  web2  web3   …all made to match

tools: Ansible, Puppet, Chef, Salt
idea : say WHAT you want, not HOW

The figure shrinks each server to two settings. Real tools manage packages, files, users and services, and each one has its own check (is it installed? is the file the same?), but the idea is the same: compare, then change only what differs. The card is real Python 3. want.items() - have.items() works because items views act like sets when every value is hashable; dict() turns the leftover pairs back into a dict.