Please enable JavaScript.
Coggle requires JavaScript to display documents.
YAML (YML) Syntax Rules – Enterprise Linux - Coggle Diagram
YAML (YML) Syntax Rules – Enterprise Linux
YAML (YML) Syntax Rules – Enterprise Linux
YAML (YAML Ain't Markup Language)
Purpose
Human-readable configuration language
Used for Infrastructure as Code (IaC)
Easy to read and write
Data serialization format
Enterprise Usage
Ansible Playbooks
Kubernetes (Pods, Deployments, Services)
Docker Compose
GitHub Actions
GitLab CI/CD
Wazuh Integrations
Elastic Stack
Prometheus
Grafana
Netplan (Ubuntu Networking)
Cloud-Init
OpenShift
Helm Charts
Interview Questions
What is YAML?
Difference between YAML and JSON?
Why is indentation important?
Why are tabs not allowed?
What is a YAML document?
YAML File Extensions
.yaml
.yml
Both are identical
Enterprise Best Practice
Use .yaml when possible for readability
Basic YAML Structure
Key
name: Bilal
Value
Ubuntu
22.04
true
false
100
Key Value Pair
username: bilal
os: ubuntu
version: 22.04
Indentation Rules (Most Important)
Spaces Only
Never use Tab
Standard is 2 spaces
Child Objects
Child keys must align
Wrong Example
Mixed tabs and spaces
Uneven indentation
Correct Example
Parent
Child
Grandchild
Enterprise Best Practice
Always use 2 spaces
Keep consistent throughout file
Interview
Why YAML fails?
Incorrect indentation
Comments
Single Line
Documentation
Explain configuration
Temporary disable configuration
Enterprise Usage
Configuration documentation
Change history
Troubleshooting notes
Data Types
String
username: bilal
Integer
port: 443
Float
version: 8.5
Boolean
enabled: true
enabled: false
Null
value: null
value:
value: ~
List
Multiple values
Dictionary
Nested key-value pairs
Strings
Unquoted
ubuntu
Single Quotes
'Ubuntu Server'
Double Quotes
"Ubuntu Server"
Multi-line String
Literal Style
|
Preserve line breaks
Folded Style
Merge lines into one
Enterprise Usage
Scripts
Certificates
SQL Queries
Log Messages
Lists (Arrays)
Syntax
Dash -
Example
packages
nginx
git
curl
Enterprise Usage
Install packages
Firewall rules
User lists
Kubernetes containers
Nested Lists
Users
name
uid
shell
Servers
hostname
ip
role
Dictionary (Map)
Structure
Parent
Child
Example
database
host
port
username
password
Enterprise Usage
Application configuration
Database configuration
API settings
Nested Objects
Company
Department
Team
User
Enterprise Usage
Inventory
Cloud resources
Kubernetes manifests
Boolean Values
true
false
yes
no
on
off
Enterprise Best Practice
Prefer true and false
Null Values
null
~
Empty value
Enterprise Usage
Optional fields
Special Characters
Colon :
Key separator
Dash -
List item
Hash #
Comment
Question ?
Complex keys
Ampersand &
Anchor
Asterisk *
Alias
Greater Than >
Folded text
Pipe
Literal block (preserves line breaks)
Anchors and Aliases
Anchor
&
Alias
*
Purpose
Reuse repeated configuration
Enterprise Usage
Kubernetes
Docker Compose
Ansible variables
Benefits
Reduce duplication
Easier maintenance
Multi-line Text
Literal
Pipe
Preserves formatting
Folded
Greater Than
Joins lines
Enterprise Usage
Certificates
Shell scripts
SQL
Application configuration
Document Separator
Start document
...
End document
Enterprise Usage
Multiple Kubernetes resources
Helm Charts
Variables
Static Variables
Dynamic Variables
Environment Variables
Secret Variables
Enterprise Usage
CI/CD
Kubernetes
Docker
Ansible
Environment Variables
Example
HOME
PATH
USER
Enterprise Usage
Container configuration
Application deployment
YAML Validation
yamllint
Install
sudo apt install yamllint
Check
yamllint file.yaml
python-yaml
Validate syntax
IDE Validation
VS Code
IntelliJ
CI/CD Validation
GitHub Actions
GitLab Pipeline
Linux Commands
Create File
touch config.yaml
Edit
nano config.yaml
vim config.yaml
View
cat config.yaml
less config.yaml
Validate
yamllint config.yaml
Search
grep
Find
find
Copy
cp
Move
mv
Remove
rm
Implementation in Ansible
Playbook
Variables
Inventory
Roles
Tasks
Handlers
Templates
Enterprise Workflow
Write playbook
Validate YAML
Run syntax check
Execute playbook
Verify results
Implementation in Kubernetes
Deployment
Pod
Service
ConfigMap
Secret
Namespace
Ingress
PersistentVolume
Enterprise Workflow
Create YAML
Validate
Apply
kubectl apply -f deployment.yaml
Verify
kubectl get all
Troubleshoot
kubectl describe
kubectl logs
Implementation in Docker Compose
Services
Networks
Volumes
Environment Variables
Restart Policy
Enterprise Workflow
Create compose.yaml
Validate
docker compose config
Deploy
docker compose up -d
Verify
docker compose ps
Implementation in Netplan
Configure interfaces
Static IP
DHCP
Gateway
DNS
VLAN
Bonding
Apply Configuration
sudo netplan apply
Verify
ip addr
ip route
Implementation in CI/CD
GitHub Actions
GitLab CI
Azure DevOps
Jenkins Pipeline
Build
Test
Deploy
Notifications
Common Syntax Errors
Using Tabs
Incorrect Indentation
Missing Colon
Duplicate Keys
Invalid Boolean
Incorrect List Indentation
Wrong Multi-line Format
Trailing Spaces
Mixing Tabs and Spaces
Missing Quotes for Special Characters
Troubleshooting
Read error line number
Validate using yamllint
Check indentation
Check duplicate keys
Verify list alignment
Verify nested objects
Test in staging before production
Enterprise Best Practices
Use 2-space indentation
Never use tabs
Keep keys descriptive
Use comments wisely
Store secrets securely
Validate before deployment
Use version control (Git)
Review changes using Pull Requests
Follow naming standards
Separate configuration by environment
Development
Testing
Staging
Production
Use YAML templates
Backup configuration
Document every configuration
Security Best Practices
Never hardcode passwords
Use Secret Management
Restrict file permissions
Encrypt sensitive values
Store credentials in Vault
Rotate secrets regularly
Audit configuration changes
Interview Preparation
What is YAML?
Why YAML is used instead of XML?
Difference between YAML and JSON?
Explain indentation rules.
Why are tabs not allowed?
Explain list and dictionary.
What is nested mapping?
What are anchors and aliases?
Explain literal and folded blocks.
What is document separator?
How do you validate YAML?
Which enterprise tools use YAML?
How does Kubernetes use YAML?
How does Ansible use YAML?
Common YAML syntax mistakes?
How do you troubleshoot YAML parsing errors?