DevOps Classroom notes 04/Feb/2026

YAML

  • Ansible works in two ways

    • adhoc commands: for each module construct a ansible command
    • playbook: A declartive approach written in a yaml file.
  • YAML is a data description format built on following principles

    • Name-value or key-value pairs
    • indentation (inspired from python)
  • YAML is a format used by both applications and humans
  • Since we deal with data where values can be of different types.
  • YAML data types
    • Simple types
      • text
      • number
      • boolean
    • Complex
      • list/array (plural)
      • map/object
  • To write a yaml file we use .yml or .yaml as extension generally
  • YAML each element syntax is <name | key>: <value>
  • Text
name: quality thought Technologies
name: 'quality thought Technologies'
name: "quality thought Technologies"
  • Number: use numbers without quotes
age: 13
  • boolean
offline: True
offline: yes
  • list or array
courses: ["DevOps", "Python"]
courses:
- DevOps
- Python
courses:
  - DevOps
  - Python
  • object/map
address:
  flatno: 601
  building: Nilgiri
  area: ameerpet
  city: hyderabad
address: { flatno: 601, building: Nilgiri, area: ameerpet, city: hyderabad }
  • Complete yaml file
---
name: quality thought Technologies
age: 13
offline: yes
courses:
  - DevOps
  - Python
address:
  flatno: 601
  building: Nilgiri
  area: ameerpet
  city: hyderabad
  • Website to learn yaml

  • When we are writing a yaml for a specific tool, there will be a structure to follow
  • Lets take yesterdays table and write them in yaml form
  • Syntax
- name: <describe your step>
  <module-name>:
    <param-1>: <value-1>
    ..
    <param-n>: <value-n>
  • The modules found in last session
Sno Command Module Parameters
1 apt update ansible.builtin.apt update_cache: true
2 apt install nginx ansible.builtin.apt name: nginx, state: present
3 systemctl enable nginx.service ansible.builtin.systemd name: nginx.service, enabled: true
4 systemctl start nginx.service ansible.builtin.systemd name: nginx.service, state: started
5 apt install unzip ansible.builtin.apt name: unzip, state: present
6 wget https://templatemo.com/tm-zip-files-2020/templatemo_589_lugx_gaming.zip ansible.builtin.get_url url: , dest: /tmp/templatemo_589_lugx_gaming.zip
7 unzip templatemo_589_lugx_gaming.zip ansible.builtin.unarchive src: /tmp/templatemo_589_lugx_gaming.zip, remote_src: true, dest: /var/www/html/

Yaml equivelent

  1. update cache
- name: update caches
  ansible.builtin.apt:
    update_cache: yes
  1. installing nginx
- name: installing nginx
  ansible.builtin.apt:
    name: nginx
    state: present
  1. enable nginx
- name: enable nginx
  ansible.builtin.systemd_service:
    enabled: yes
    name: nginx.service
  1. start nginx
- name: ensure nginx is started
  ansible.builtin.systemd_service:
    name: nginx.service
    state: started

you fill the rest.

  • To learn yaml use the following prompt.
Act as yaml tutor, Give me simple data and a question to write yaml, i will fill the yaml structure and you validate, correct and make me learn yaml

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube