Please enable JavaScript.
Coggle requires JavaScript to display documents.
Phase 3 — YAML (YAML Ain't Markup Language) - Coggle Diagram
Phase 3 — YAML (YAML Ain't Markup Language)
Introduction to YAML
What is YAML
Human-readable data serialization language
Used to describe structured data
Primary language for Ansible Playbooks
Stores configuration instead of program logic
Uses indentation instead of braces or brackets
Why Ansible Uses YAML
Easy to read
Easy to maintain
Platform independent
Version control friendly
Less syntax compared to JSON or XML
YAML File Extensions
.yml
.yaml
YAML Rules
Indentation is mandatory
Use spaces only
Never use tabs
Standard is 2 spaces
Case sensitive
Keys must be unique
Comments begin with #
One key per line
Values follow :
Lists begin with -
Dictionary uses key:value pairs
YAML Data Types
String
Integer
Float
Boolean
List
Dictionary
Null
YAML Syntax Fundamentals
Key Value Pair
name: nginx
state: started
String Values
Unquoted String
Single Quoted String
Double Quoted String
Multi-line String
Literal Style
Folded Style
Numbers
Integer
Floating Point
Boolean
true
false
yes
no
on
off
Null Values
null
~
Comments
Single Line Comment
Inline Comment
Variables
What are Variables
Store reusable values
Reduce duplication
Increase flexibility
Variable Naming Rules
Lowercase
Underscore
No spaces
Cannot begin with number
Variable Types
String Variables
Integer Variables
Boolean Variables
List Variables
Dictionary Variables
Variable Declaration
Inline Variables
vars Section
vars_files
include_vars
set_fact
Registered Variables
Inventory Variables
Group Variables
Host Variables
Extra Variables
Variable Scope
Play Level
Task Level
Role Level
Inventory Level
Global Variables
Variable Precedence
Extra Variables
Task Variables
Block Variables
Role Variables
Play Variables
Inventory Variables
Facts
Role Defaults
Variable Interpolation
Double Curly Braces
Access Variables
Nested Variables
Variable Filters
default
upper
lower
capitalize
title
replace
trim
length
join
split
unique
sort
first
last
random
int
float
bool
to_json
to_yaml
from_json
from_yaml
Lists
What is a List
Ordered collection
Multiple values
List Syntax
List Index
Starts from zero
Access List Elements
Nested Lists
Loop Through Lists
List Filters
first
last
unique
sort
reverse
length
min
max
flatten
Enterprise Uses
Package Installation
User Creation
Service Management
Firewall Rules
Multiple Servers
Dictionary
What is Dictionary
Key Value Collection
Dictionary Syntax
Nested Dictionary
Access Dictionary Values
Dictionary Methods
Merge Dictionaries
Combine Dictionaries
Dictionary Filters
dict2items
items2dict
Enterprise Uses
Server Configuration
Application Configuration
User Attributes
Network Configuration
Nested Dictionary
What is Nested Dictionary
Parent Dictionary
Child Dictionary
Multiple Levels
Access Nested Values
Combine Nested Data
Enterprise Examples
Server Inventory
Cloud Resources
Network Devices
Storage Configuration
Boolean
What is Boolean
True
False
Boolean Keywords
true
false
yes
no
on
off
Boolean Operations
Equal
Not Equal
Greater Than
Less Than
Greater or Equal
Less or Equal
Enterprise Examples
Enable Service
Disable Firewall
Enable SELinux
Enable Maintenance Mode
Loops
What is Loop
Repeat Tasks
Loop Syntax
Loop Types
loop
with_items
with_list
with_dict
with_sequence
with_file
with_lines
with_inventory_hostnames
with_nested
with_subelements
Loop Variables
item
ansible_loop
loop_control
loop_control
label
pause
extended
index_var
Register Loop Output
Nested Loops
Enterprise Uses
Package Installation
User Creation
Directory Creation
Multiple Services
Firewall Rules
Multiple Hosts
Conditions
What are Conditions
when Statement
Comparison Operators
==
!=
<
=
<=
Logical Operators
and
or
not
Membership Operators
in
not in
Condition Based on Facts
Condition Based on Variables
Multiple Conditions
Conditional Loops
Enterprise Uses
Different Linux Distributions
Service Status
Package Availability
OS Version
Maintenance Windows
Blocks
What is Block
Why Use Block
Group Tasks
Error Handling
Readability
Block Structure
block
rescue
always
Block Variables
Block Conditions
Block Tags
Nested Blocks
Enterprise Uses
Application Deployment
Database Upgrade
Patch Management
Backup Process
Service Restart
Error Handling
ignore_errors
failed_when
changed_when
retries
delay
until
rescue
always
any_errors_fatal
max_fail_percentage
Tags
What are Tags
Purpose
Execute Selected Tasks
Faster Automation
Tag Syntax
Run Tagged Tasks
Skip Tags
Multiple Tags
Special Tags
always
never
tagged
untagged
all
Enterprise Tag Design
install
configure
update
security
patch
backup
monitoring
database
webserver
application
firewall
users
validation
Handlers
What is Handler
Special Task
Runs only when notified
Why Use Handlers
Prevent unnecessary restarts
Improve efficiency
notify Directive
Handler Execution
Multiple Notifications
listen Keyword
flush_handlers
Handler Order
Handler Scope
Enterprise Uses
Restart Apache
Restart Nginx
Restart SSH
Restart Docker
Restart PostgreSQL
Restart MySQL
Reload Systemd
Reload Firewall
Reload SELinux Policy
YAML Anchors and Aliases
Anchors
Aliases
Merge Keys
Reusable Configurations
Enterprise Configuration Reuse
Jinja2 in YAML
Variable Interpolation
Expressions
Filters
Tests
Control Structures
if
else
for
Default Values
String Manipulation
Mathematical Operations
Date Operations
Facts in YAML
What are Facts
Gathering Facts
ansible_facts
Custom Facts
Local Facts
Accessing Facts
Fact Caching
YAML File Organization
Enterprise Directory Structure
playbooks
inventories
group_vars
host_vars
roles
collections
files
templates
vars
defaults
handlers
tasks
meta
library
filter_plugins
Naming Standards
File Permissions
Documentation Standards
YAML Best Practices
Use Meaningful Variable Names
Keep Files Small
Avoid Hardcoded Values
Store Secrets in Vault
Use Group Variables
Use Host Variables
Use Roles
Use Handlers
Use Tags
Use Blocks
Validate Syntax
Follow Indentation Standards
Use Comments
Version Control with Git
Peer Review
Testing Before Production
YAML Validation
ansible-playbook --syntax-check
yamllint
ansible-lint
Check Mode
Diff Mode
Enterprise Troubleshooting
Indentation Errors
Missing Colon
Invalid Boolean
Duplicate Keys
Undefined Variables
Loop Errors
Dictionary Errors
List Errors
Template Errors
Handler Not Triggered
Tag Not Working
Block Failure
Variable Precedence Issues
YAML Parsing Errors
Enterprise Real World Examples
User Management
Package Management
Service Management
Patch Management
Security Hardening
Web Server Deployment
Database Deployment
Firewall Configuration
SELinux Configuration
SSH Hardening
Monitoring Agent Deployment
Backup Automation
Log Rotation
Certificate Deployment
Kubernetes Node Configuration
Docker Host Configuration
VMware Virtual Machine Configuration
AWS EC2 Provisioning
Azure Virtual Machine Configuration
Multi-Environment Deployment
Development
Testing
Staging
Production
Enterprise Learning Outcome
Understand YAML Syntax
Create Complex Variables
Work with Lists
Work with Dictionaries
Build Nested Data Structures
Apply Boolean Logic
Use Loops Efficiently
Write Conditional Tasks
Group Tasks with Blocks
Control Execution with Tags
Optimize Automation with Handlers
Follow Enterprise Best Practices
Troubleshoot YAML Errors
Build Production Ready Ansible Playbooks