Mastering Variables, JSON & YAML
This week, I focused on the building blocks of configuration and automation in DevOps: variables, JSON, and YAML. These are essential for writing reusable, flexible, and structured code in modern Infrastructure as Code tools like Ansible, Terraform, Kubernetes, and CI/CD pipelines.
π What I Learned:
π Variables in DevOps Scripts
Used variables in Bash scripts and Vagrantfile to make VM provisioning more dynamic.
Learned about environment variables (export VAR=value), default values, and scope (global vs local).
π JSON (JavaScript Object Notation)
Understood its role in config files, REST APIs, and cloud resource provisioning.
Practiced working with nested structures and arrays.
Learned to format, validate, and parse JSON for better readability.
π§Ύ YAML (YAML Ainβt Markup Language)
Explored YAMLβs clean, readable syntax used in Docker Compose, GitHub Actions, Kubernetes, and Ansible.
Learned best practices like using spaces over tabs, document separation (---), and correct indentation.
Compared YAML vs JSON for real-world config management.
π Resources That Helped:
π Learn YAML in Y Minutes: https://learnxinyminutes.com/docs/yaml
π JSON vs YAML β Whatβs the Difference?: https://www.json2yaml.com
πΊ JSON & YAML Crash Course (YouTube): https://www.youtube.com/watch?v=cdLNKUoMc6c
π DevOps Variable Guide by Educative: https://www.educative.io/blog/devops-variables
β JSON Formatter & Validator: https://jsonlint.com
π οΈ Key Tasks I Completed:
β Declared and used variables in Vagrant and shell scripts.
β Created and validated multi-layered JSON files for configurations.
β Wrote YAML files for simulated Kubernetes pods and CI/CD pipelines.
β Converted JSON β YAML for better readability and compatibility.
β Identified and fixed common errors like wrong indentation and syntax.
β οΈ Common Errors & Quick Fixes:
β Error
π‘ Solution
bad indentation in YAML
Use only spaces, no tabs. Tools like YAML Lint help.
unexpected end of JSON input
Use JSONLint to find missing commas/brackets.
Variable not found
Ensure itβs exported (export VAR=value) and accessed correctly ($VAR)
YAML list parsing issues
Use - consistently and maintain indentation levels.
π― My Takeaway:
Variables, JSON, and YAML may seem basic β but theyβre the language of automation. From Vagrant to Kubernetes, understanding these formats helps you control, scale, and debug infrastructure with precision.
Letβs connect if youβre learning YAML, writing automation configs, or exploring Infrastructure as Code!
Top comments (0)