In this post, You learn questions and answers.

what is YAML?

YAML abbreviated as Ain’t Markup Language is serialization for storing configuration data. It is easy to read by humans.

It is similar and superset to JSOn with easy readable with minimal syntax It supports multiple programming languages for reading and writing yaml files and extension is .yaml These are used for resource configuration and deployment pipelines by automated build tools like Ansible and Kubernetes. YAML file contains key and value pairs with data format syntax rules.

Key is a string, and values are scalar, list, and map types.

IDE plugins or extensions that support syntax, yaml lint auto-format, and validate errors. Content of the file can be validated using validation tools.

How to create yaml files?

a simple notepad tool or popular IDES like Visual Studio, Sublime, and ATOM used to create a yaml file.

YAML file contains content like text or json file with extension is .yaml. These extensions are not standard, but can also use .yml extension.

Writing content in the yaml file follows some syntax rules for key and value types.

There is no support for the format in the notepad. IDE provides plugins or extensions to the auto-format, syntax validation, and linting the content of a file.

Also, Some online tools provide to create and validate yaml files.

Does Ansible uses YAML or JSON files?

Ansible uses YAML for writing playbooks by default. Ansible does not support json format as YAML is easy to read and write with the human-readable data format. Ansible playbooks contain yaml code to play and automate the process.

IS YAML and JSON are same or different?

To configure environment details, YAML and json are both used as data format serialization languages. YAML is a superset of JSOn with more advanced features.

Both support popular languages such as java, python, and nodejs.

YAML files are more readable than JSON, However processing JSON files are faster compared with YAML files.

JSON content in the yaml file is valid whereas valid yaml is not included in the JSON file.

JSON is more of a data agreement format used to send and receive between client and server systems. YAML is more of configuration storing data for different environments like QA, STAGE, and PRODUCTIOn for deployments and build process

for example, the YAML array example is declared as follows

countries: [INDIA,USA, EUROPE,GERMANY,SINGAPORE]

the same above can be rewritten in json as follows

{
  "countries": [
    "INDIA",
    "USA",
    "EUROPE",
    "GERMANY",
    "SINGAPORE"
  ]
}