Day 15 : Python Libraries for DevOps
Reading JSON and YAML in Python
As a DevOps Engineer you should be able to parse files, be it txt, json, yaml, etc.
You should know what all libraries one should use in Pythonfor DevOps.
Python has numerous libraries like
os,sys,json,yamletc that a DevOps Engineer uses in day to day tasks.
Task 1: Create a Dictionary in Python and write it to a json File.

- Read a json file
services.jsonkept in this folder and print the service names of every cloud service provider.
services.json :
{
"services": {
"debug": "on",
"aws": {
"name": "EC2",
"type": "pay per hour",
"instances": 500,
"count": 500
},
"azure": {
"name": "VM",
"type": "pay per hour",
"instances": 500,
"count": 500
},
"gcp": {
"name": "Compute Engine",
"type": "pay per hour",
"instances": 500,
"count": 500
}
}
}

- Read YAML file using python, file
services.yamland read the contents to convert yaml to json
services.yaml :
---
services:
debug: 'on'
aws:
name: EC2
type: pay per hour
instances: 500
count: 500
azure:
name: VM
type: pay per hour
instances: 500
count: 500
gcp:
name: Compute Engine
type: pay per hour
instances: 500
count: 500

This was it for day 15. If you have any suggestion/questions please comment below.
Looking forward to next challenge.
Happy coding.



