Hands-on Lab·Python Automation for IT
Python YAML, INI and TOML Configuration
Four configuration formats, and the choice between them is mostly about types. INI gives you strings and nothing else. JSON and TOML give you real types and refuse anything ambiguous. YAML gives you real types and guesses aggressively - which is why `[NO, SE, DK]` comes back as `[False, 'SE', 'DK']`. This guide reads the same five settings from all four and shows exactly what each hands over.
Files and Data Formats Guide 13 of 39 Intermediate
- Python3.14.4
- Control nodeUbuntu 26.04 LTS
- Managed hostsRHEL 10.0
- requests2.34.2
- paramiko5.0.0
- pytest9.1.1
- PyYAML6.0.3
- boto3 / botocore1.43.78
- TimeAbout 19 min
- Reviewed24 August 2026
Written against the versions above. `tomllib` arrived in **Python 3.11** and is read-only. `configparser` and `json` are unchanged. PyYAML is the only third-party dependency here, because there is no YAML parser in the standard library at all.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Control node - every script in this path runs here | 2 Core | 4 GB | 50 GB |
Before you start
- guide 12 - JSON is the baseline the others are compared against.
- guide 7 - where a config file sits in the precedence order.
-
The same five settings, four ways
-
What each one gives back
-
INI is strings, and the conversion helpers
-
TOML and YAML give you real types
-
tomllib reads and does not write
-
Writing INI and JSON back out
-
What YAML decides your values mean
-
The Norway problem, and two more like it
-
The YAML that does not fail and should
-
Malformed, in each format
-
Which one to use