Sign inSign up free

1440. Detect Configuration Drift Between Two Environments

medium 20 XP ~12 minHands-on lab

Staging and production should differ only where intended. Write /home/student/config/drift.py A.json B.json to show the differences between two configs.

Task

Walk both files. Nested objects are compared key by key, and paths are written with dots (db.pool.max). Anything that isn't an object (including lists) is compared as a whole. Print, sorted by path:

  • + PATH = VALUE for a path only in B,
  • - PATH for a path only in A,
  • ~ PATH: OLD -> NEW for a path in both with different values,

where values are printed as JSON (json.dumps, so strings keep their quotes). When the files are the same, print no drift and exit 0; otherwise exit 1.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Python for DevOps. Next step: Verify Files Against a Checksum Manifest

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.