In this post, you will find questions and their corresponding 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 easily readable with minimal syntax It supports multiple programming languages for reading and writing yaml files and the 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.

The 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. The 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 .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 of the content of a file.

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

Does Ansible use 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.

Are 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 is 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 a configuration storing data for different environments like QA, STAGE, and PRODUCTIOn for deployments and builds 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"
  ]
}