Build an Ops Toolkit, Stage 2: Layered Configuration
This is stage 2 of the opskit project. You keep working in ~/opskit: your code from stage 1 is already there, and it's saved as you work. Starting here without the earlier stages? A working version of them was put in for you. Run the tool from ~/opskit with python3 -m opskit ....
Add a global option --config FILE (it comes before the command) and the command config:
opskit config show prints the configuration as JSON (indent=2, sorted keys). It's built in layers:
threshold 90, services [], webhook_url null, log_file "/var/log/nginx/access.log";--config FILE, or else ~/.config/opskit/config.json; its keys replace the defaults (extra keys are kept);OPSKIT_THRESHOLD (a whole number) replaces threshold, OPSKIT_WEBHOOK replaces webhook_url.opskit config get KEY prints one value: strings as they are, anything else as JSON.--config file, invalid JSON, a non-number OPSKIT_THRESHOLD or an unknown key: a one-line error on stderr and exit 2, never a traceback.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.
Project: Build an Ops Toolkit in Python · stage 2 of 8
Create a free account to keep your code between stages.
Teaching or writing about this? Embed this lab on your page
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.