Friday, April 17, 2026

yaml_Ansible

 YAML Data Types


YAML organizes data using three basic data types: scalars, sequences, and maps. Each of these data types has its own syntax and structure.

1. Scalars
A scalar is a single value, such as a string, number, or boolean. Scalars can be represented in various ways in YAML, including plain style, double-quoted style, and single-quoted style.
name: Alagarasan
age: 30
is_devops_consultant: true
In the above example, name is a string scalar, age is a numeric scalar, and is_devops_consultant is a boolean scalar.

Key value
key: value
key = name
: = Seprator. # Space after colon is mandatory
value = data


String
Text values (quoted or unquoted)
name: Alagarasan
role: "DevOps Engineer"
company: 'TCS'

Integer (Number)
Numeric values without a decimal point (whole numbers)
age: 30
experience: 8

Float (Number)
Numeric values with a decimal point (floating-point numbers)
cpu_usage: 75.5
version: 1.2

Boolean
True or false values
is_active: true
is_admin: false

Null (Empty value)
null is not a string, It represents absence of value
Null (Empty value)
null means:👉 No value / empty value / nothing assigned
~ is a shorthand for null in YAML. It represents the absence of a value, similar to null in other programming languages. When you see ~ in a YAML file, it indicates that the value is intentionally left empty or not assigned.
value1: null
value2: Null
value3: NULL
value4: ~
value5:

eg
user:
name: Alagarasan
middle_name: null
nickname: ~
age: 30
is_active: true




NAN (Not a Number)
NaN stands for: Not a Number. It is a special floating-point value that represents an undefined or unrepresentable value, such as the result of dividing zero by zero.
result: .nan
result: .NaN
result: .NAN

eg
metrics:
cpu_usage: 75.5
memory_usage: .nan
👉 Here:
cpu_usage → valid number
memory_usage → undefined / not measurable


.infinite (INF)
INF stands for: Infinity. It is a special floating-point value that represents an infinitely large number
positive_infinity: .inf
negative_infinity: -.inf
also_positive_infinity: .INF
also_negative_infinity: -.INF

Positive vs Negative Infinity

positive: .inf
negative: -.inf

👉 Meaning:
.inf → +∞
-.inf → −∞

No comments:

Post a Comment