|
| 1 | +# Day 38 – YAML Basics |
| 2 | + |
| 3 | +## Task |
| 4 | +Before writing a single CI/CD pipeline, you need to get comfortable with **YAML** — the language every pipeline is written in. |
| 5 | + |
| 6 | +You will: |
| 7 | +- Understand YAML syntax and rules |
| 8 | +- Write YAML files by hand |
| 9 | +- Validate them |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Expected Output |
| 14 | +- A markdown file: `day-38-yaml.md` |
| 15 | +- YAML files you create during the tasks |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Challenge Tasks |
| 20 | + |
| 21 | +### Task 1: Key-Value Pairs |
| 22 | +Create `person.yaml` that describes yourself with: |
| 23 | +- `name` |
| 24 | +- `role` |
| 25 | +- `experience_years` |
| 26 | +- `learning` (a boolean) |
| 27 | + |
| 28 | +**Verify:** Run `cat person.yaml` — does it look clean? No tabs? |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +### Task 2: Lists |
| 33 | +Add to `person.yaml`: |
| 34 | +- `tools` — a list of 5 DevOps tools you know or are learning |
| 35 | +- `hobbies` — a list using the inline format `[item1, item2]` |
| 36 | + |
| 37 | +Write in your notes: What are the two ways to write a list in YAML? |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +### Task 3: Nested Objects |
| 42 | +Create `server.yaml` that describes a server: |
| 43 | +- `server` with nested keys: `name`, `ip`, `port` |
| 44 | +- `database` with nested keys: `host`, `name`, `credentials` (nested further: `user`, `password`) |
| 45 | + |
| 46 | +**Verify:** Try adding a tab instead of spaces — what happens when you validate it? |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +### Task 4: Multi-line Strings |
| 51 | +In `server.yaml`, add a `startup_script` field using: |
| 52 | +1. The `|` block style (preserves newlines) |
| 53 | +2. The `>` fold style (folds into one line) |
| 54 | + |
| 55 | +Write in your notes: When would you use `|` vs `>`? |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### Task 5: Validate Your YAML |
| 60 | +1. Install `yamllint` or use an online validator |
| 61 | +2. Validate both your YAML files |
| 62 | +3. Intentionally break the indentation — what error do you get? |
| 63 | +4. Fix it and validate again |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +### Task 6: Spot the Difference |
| 68 | +Read both blocks and write what's wrong with the second one: |
| 69 | + |
| 70 | +```yaml |
| 71 | +# Block 1 - correct |
| 72 | +name: devops |
| 73 | +tools: |
| 74 | + - docker |
| 75 | + - kubernetes |
| 76 | +``` |
| 77 | +
|
| 78 | +```yaml |
| 79 | +# Block 2 - broken |
| 80 | +name: devops |
| 81 | +tools: |
| 82 | +- docker |
| 83 | + - kubernetes |
| 84 | +``` |
| 85 | +
|
| 86 | +--- |
| 87 | +
|
| 88 | +## Hints |
| 89 | +- YAML uses **spaces only** — never tabs |
| 90 | +- Indentation is everything — 2 spaces is standard |
| 91 | +- Strings don't need quotes unless they contain special characters (`:`, `#`, etc.) |
| 92 | +- `true`/`false` are booleans, `"true"` is a string |
| 93 | +- Validate online: yamllint.com |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## Documentation |
| 98 | +Create `day-38-yaml.md` with: |
| 99 | +- Your YAML files |
| 100 | +- What you learned (3 key points) |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Submission |
| 105 | +1. Add your YAML files and `day-38-yaml.md` to `2026/day-38/` |
| 106 | +2. Commit and push to your fork |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Learn in Public |
| 111 | +Share your YAML "aha moment" on LinkedIn — the tab vs space mistake gets everyone. |
| 112 | + |
| 113 | +`#90DaysOfDevOps` `#DevOpsKaJosh` `#TrainWithShubham` |
| 114 | + |
| 115 | +Happy Learning! |
| 116 | +**TrainWithShubham** |
0 commit comments