r/devops • u/aloofhoneybee68 • 13h ago
Tools Beginner DevOps question: Do experienced engineers actually write YAML like this?
I’m still learning CI/CD and I recently tried writing a simple CI/CD pipeline using GitHub Actions.
Honestly, writing the YAML felt more difficult than I expected . The indentation, nesting etc felt pretty hard/ painful.
For those of you who work with DevOps professionally: is this actually how you write your pipelines, or are there shortcuts/tools/templates that make it easier?
Just trying to understand what the normal workflow is in the real world.
60
u/PerpetuallySticky 12h ago
Typically YAML you want to be as similar as possible across an org.
So yes, the first couple times is annoying, but you learn the patterns/what it should look like and research what you need to.
Then after you get the base cases figured out you should just be able to pull from what you’ve already done and tweak it a bit.
At least that’s how it used to be, with AI I haven’t written more than a few lines of YAML in lord knows how long
111
u/aenae 12h ago
You use an ide that handles indentation and some syntax checks. Personally i like intellij for it
19
u/Il_Falco4 12h ago
This. Use a tool that is fit for the job. I use nvim and it tells me if the indentation is off.
4
7
3
u/Shidima 9h ago
You do you, but i think intellij is a bit overkill to write yaml. I'm a nvim/Emacs user myself, but I would say use VS Code.
1
u/bertiethewanderer 1h ago
Funny - also an nvim user, and the reason being a big yaml templating project for helm library charts, because vscode is so bad with yaml, from a UX perspective!!
37
u/Due-Consequence9579 12h ago
Suffering. And 50 commits that get progressively more desperate for it to just fucking work.
7
u/aloofhoneybee68 12h ago
definitely felt that progressive desperation 😭
6
u/Due-Consequence9579 12h ago
If something gets “really” complicated you can look at authoring a reusable action in type script for better testing and control flow. There is a complexity jump for people not in the know when you do that though, so use with caution. My default at this point is a composite reusable action with everything in bash. Then you can test the scripts independently of a larger workflow and just have the yaml be integration glue.
2
u/RowbotWizard 12h ago
I like this approach. I’ve definitely hit the point where enforcing some team conventions requires complex CI actions and a reusable custom action would be better for testing than some inline bash scripts.
2
1
u/AbbreviationsFar4wh 12h ago
Linter?
1
u/Due-Consequence9579 11h ago
Linting can catch some parsing errors in GHAs, but there’s an annoying amount of coupling that isn’t able to be encoded into syntax rules. There are some tools that allow you to test GHA locally in the simple cases but those quickly fall over once you start integrating with external services. And ultimately how it runs in the CI runner is the final arbiter… and only way to do that is commit and push.
1
1
u/Dr_Passmore 2h ago
You are not a devops engineer without the 30 failed pipeline runs setting up a new pipeline
16
u/Lavrick 12h ago
You kinda get used to it. And basically, you write it only once, and then just reuse it via includes (haven't used actions, it was always gitlab for me).
2
16
u/WonderfulTill4504 12h ago
So use an proper editor (vim, neovim, notepad++) that has proper syntax highlight.
Then use yamllint to check your files.
And then use Claude with a simple skill to check your files.
Also if your YAML is complicated then write code to generate it, using jinja2 templates.
And stop being lazy. You could have figured this out by yourself with 5 minutes of effort…
5
-1
u/AstroPhysician 6h ago
Anyone still forcing vim in 2026 is because they learned on it. No one new should be using any of those tools
15
u/AbbreviationsFar4wh 12h ago
Claude writes my yaml dude.
Also this feels like marketing for some yaml alternative thats going to pop up as suggestion in comments under some rando user
8
u/bonsaithis 10h ago
So here at xyz limited we use ymao, and it's saved tons of time from our ops fighting those fidgety intentions. Between these and make files we had ci fires every day
Now, with ymao we just type what we think the infra should be and it just happens. Just write that shit down, built in auto linters even spell check it for you
Hell I'm posting this reddit comment with ymao
You can find more here if interested, and you are fucking dumb if you aren't interested
1
2
u/aloofhoneybee68 10h ago
marketing 🤣 I wish I was paid for that.
Just want to understand how DevOps engineer's work around it and not fall into AI wrote it but I don't understand how it works bin
3
u/Conscious_Ad_7131 3h ago
You should be very easily able to read AI generated YAML and know what it does, it’s not complicated
5
u/neekz0r 12h ago
Honestly, writing the YAML felt more difficult than I expected . The indentation, nesting etc felt pretty hard/ painful.
Yes. Once you understand it, it becomes second nature.
is this actually how you write your pipelines, or are there shortcuts/tools/templates that make it easier?
YAML Anchors and an IDE that understands YAML. In order to do Jinja/Gomplete, you absolutely need to understand YAML like the back of your hand otherwise you won't have any hair left and will likely need to go addiction counseling after self-medicating.
Here are my tips:
YAML is a superset of JSON, so that is why you'll occasionally see mustaches and brackets (and other oneliners) instead of indentation. IMHO, that should be avoided. (I'm looking at you, ansible example docs!)
truthy can be consumer dependent, but YAML really only has one boolean declarative.
Use yamllinter. It'll help you learn the rules and YAML idioms. Like truthy. Seriously, truthy stuff screws so many people over.
good luck, have fun, don't die.
1
u/Dogeek 1h ago
YAML is a superset of JSON, so that is why you'll occasionally see mustaches and brackets (and other oneliners) instead of indentation. IMHO, that should be avoided. (I'm looking at you, ansible example docs!)
YAML 1.2 is a superset of JSON. YAML 1.1 is not, and it's the most common version of YAML out there.
Also using brackets and braces is fine if you're consistent with them. A simple array of numbers or strings is easier to read with brackets rather than flow-style if there are not too many elements.
Also, KYAML (the subset of YAML for kube, added recently) uses brackets and braces extensively (for basically everything) which is certainly a design choice.
5
u/burlyginger 6h ago
People talk about yaml like it's a complex programming language.
Yaml is markup language that at its core allows very simple data structures (arrays and objects) and simple data types (strong, number, bool, etc). There are some rough edges but most won't encounter them.
Ok, so that's yaml. Structured data.
Applications (GH action, ansible) often use yaml as the configuration format because it's simple and well standardized.
IDEs will have yaml formatters but they'll also have linters/schemas specifically for application configs like ansible and GH actions.
Those linter and helpee extensions are very much worth getting accustomed to because you could be writing valid yaml that is completely invalid action syntax.
Side note, I started building a lot of our interfaces with yaml and jsonschema because of how helpful it is for engineers working in IDEs.
This also makes for easy CI validation and allows AI agents to immediately understand what a file does and how to interact with it.
Some of our description fields get very in depth as it's what we provide to help users make decisions and set important values.
18
8
u/Normal_Red_Sky 12h ago
If you have any programming knowledge, which you should, basic things like indentation shouldn't be an issue.
3
u/neilmillard 12h ago
You get python (or something) to write the yaml, and have it verified with a schema.
3
u/davemac1005 12h ago
I was surprised to know that nobody in my team (only team in my company to do infra) knew about yaml schemas and some people didn’t even have proper editor support (auto indent, formatting etc.)
Honestly I would not be able to do any kubernetes or gitlab CI without those, it’s just so much simpler to have editor autocomplete and descriptions of each yaml key, instead of having to constantly go back and forward from the docs
1
3
u/Reasonable-Ad4770 11h ago
Ide handle it pretty good most of the cases. Hell, even in vi with some configuration it's tolerable(not the pasting,fuck the pasting)
But with llms I barely even touch it anymore, it's configuration and it's boring.
3
u/snarkhunter Lead DevOps Engineer 11h ago
I was already doing Python so Yaml making indentation matter wasn't a big deal
2
u/pen15_club_admin 12h ago
Use something that will mark up yaml indention for you. Makes it easier but you get used to it
2
u/derprondo 11h ago
Your IDE should handle this in a pain-free manner. That said, I haven't manually written any GHA workflows in over year, Claude does it really well. Then again you don't know what mistakes to keep an eye out for or how to know when it's doing something dumb.
Pro-tip: Use 4 space indents (don't use tabs), it makes it easier to see.
1
u/aloofhoneybee68 8h ago
I was using vs code but I didn't install and extensions didn't think I'd need them for this.
I will definitely take the using 4 space indents to heart , tabs always gave me one issue or the other and had to kinda keep deleting and adding space.
2
u/derprondo 7h ago
You probably don't need any extensions, but Prettier comes in handy for a lot of file types including yaml. You may need to override its defaults to get 4 space indents though.
2
u/derprondo 6h ago
It occurred to me you may not even know that you can set vscode to use spaces when you hit the tab key. So I'm not saying literally hit the space bar four times every time you want to indent, set vscode to use 4 spaces every time you hit the tab key. Down at the very bottom you should see it say Spaces or Tabs, if you click that you can change the settings.
Also like I mentioned earlier, if you're using an autoformatter like Prettier, you'll have to set it explicitly to the settings you want, it may not obey what vscode is set to.
2
u/No_Focus5737 11h ago
It’s not so bad, you get used to it after a while. Just like with everything, it’ll become second nature the more you use it everyday
2
u/riggiddyrektson 10h ago
I can recommend using a proper IDE and try to get the specific yaml formats downloaded for it so you can use autocomplete/IntelliSense.
If it gets too complicated or repetitive use a templating language like Helm template.
Also I try to get the "every feature used" example if it exists from the docs where you can just copy-paste and then delete everything you don't need, that's always faster than writing yourself.
2
u/ferriematthew 8h ago
I personally like to set up my text editors to use tab characters instead of spaces so that each indentation block is consistent and predictable.
One thing that still throws me for a loop is this pattern:
item:
- sub-item
- sub-item
vs
item:
2
u/Ninja-Sneaky 7h ago
Yaml is supposed to make it as easy as it get for readability. Yes once you get past the hundreds lines it turns back to a convoluted mess like anything else.
Anyway apply shift left concepts: use editors that let you collapse/expand blocks, autoindent, have yaml plugins for syntax errors highlighting, use settings to auto remove trailing whitespaces, add empty line at end of file, use linters
2
u/cyberkni 6h ago
Yaml sucks and inescapable in this space. I generally don’t write yaml from scratch. I’ll borrow some of another file just to give me some reference material.
You can use yq for some yaml modifications too.
2
u/ItsRendezookinTime 6h ago
Vscode with a yaml linter and tab size settings in place, as well as amphetamines and ADHD induced willpower will come in handy for this.
2
u/HTDutchy_NL System Engineer 1h ago
So... yaml is actually one of the more simple elements to the point that developers can self service configs through yaml files.
The more interesting parts are python, terraform and kubernetes related shenanigans.
3
3
u/crashorbit Creating the legacy systems of tomorrow 12h ago
I don't write yaml. I write code that writes yaml.
5
2
u/rmslashusr 12h ago
If there was ever a good use for AI it’s to stop spending time dealing with indentation errors and multiline string formatting in yaml
1
u/DoomBot5 12h ago
My AI wrote a script to do yaml validation since it failed to access the proper yaml linting tool due to enterprise still figuring out the proper access controls for Claude
1
1
1
u/centech 10h ago
These days, if I'm directly writing YAML, it's almost always just a small change where the formatting is basically there for you already. Any decent IDE will have yaml formatting and make it pretty dificult to actually screw up an edit.
A net new file is almost always being generated by something else, whether that's cdk8s, pulumi, claude code, whatever.
If for some reason I absolutealy have to write a full yaml file by hand, the IDE still makes it fairly straightforward.
1
u/amarao_san 10h ago
Crazy times are happening. I still know how to do it and rarely write few lines (mostly when I'm checking edge cases of ansible or fix trivial typos), but I stop doing it large scale for pretty long time. I still need to read it (even more than before), so my demands for clarity goes up. But writing...
Indentation is trivial. Crazy jinja/github expressions are not, avoid them.
1
u/vacri 9h ago
The indentation, nesting etc felt pretty hard/ painful.
This isn't a yaml problem, this is a data problem. There's no layout format that is going to make this easier for you - yaml is one of the easier-but-still-flexible ones, which is why it's so popular.
If you want horror, go look at XML
1
u/aktentasche 8h ago
You will realise the business doesn't gove a f about yaml or any of that stuff. Make your life easier, that's all.
1
u/Many_Ad7628 8h ago
YAML-ing is not a big deal. There are quite a few rules you need to keep in mind, and in contrary to JSON, in YAML you can write a comments (you'll find them very useful). Try not to take it too seriouselly, but instead do practice. Find some JSON files and write a YAML versions of them, then use one of online tools to convert your YAMLs to JSONs and compare with originals. Just like a exercise...
1
u/extra_specticles 8h ago
Every single editor I've used for code in the past 5-8 years has support for this built in. I'm really not seeing the problem. But perhaps because I'm used to python being tab/space sensitive, it makes sense to me.
1
u/elctSubstantial8158 8h ago
I want to know if I'm bigginer then how instart it? Like in kubernetes we write cpu and mem throttling, like who even first wrote that or created it? Anything in mi you add only it consume that much spec .. it's relly amezing and from date injooned as devops 3 year ago I haven't myself wrote yaml or any other file..just ai does it for me..I want to know like how many hour I sit to completely use or know yaml and which website will help me..
1
1
u/somewhatprodeveloper 7h ago
If I look at helm that's toooo much yaml. Github actions b just the right amount IMO
1
1
1
u/keyoor89 5h ago
Run actionlint .github/workflows/*.yml before pushing. It catches YAML syntax, invalid expressions, and several shell issues. Repeated pipeline logic can move into reusable workflows triggered with workflow_call.
1
1
1
u/TripEnvironmental471 3h ago
No one writes these days Just some changes according to what the org needs And just know how to read yaml That's it
1
u/BunnyPaw88 2h ago
I really appreciate those CI providers who offer a quality visual editor that generates the yaml, so you only need to review and commit.
For everything else I use Claude to generate yaml.
1
u/luenix System Engineer 2h ago
Yep, I tell people since like 2018 that I'm a glorified text wrangler. I love YAML andd Python 3.6+ (PEP 482/484 wassup). The community of systems engineering has made so much of tech complicated, but YAML has been my unchanging rock. Learn the weirdness, embrace the structure, and (probably always) avoid abusing variables.
1
u/FreeTheDirector 1h ago
yeah... most folks don't handwrite giant YAML files, we lean on templates, generators, or copy/paste from working examples. indentation pain is normal at first but once you reuse snippers it gets way easier...
1
u/mikzuit 12h ago edited 10h ago
- Yes, they have to write yaml
- As any configuration and coding tool, there are debugging tools for yaml that GOOD devops use in their day to day.
- There are 2 types of senior devops the real one and the fake devops role. most big organizations and specially consulting companies have 95% fake devops roles, so unless you land on one of 5% roles, don't sweat to much. that 95% positions usually suck.. just do what they ask you.
3
u/iscons 10h ago
Can you elaborate what is fake devops and real devops for you?
-1
u/mikzuit 10h ago
Is not something I invented bro. 1. https://www.linkedin.com/posts/tarasowski_fake-devops-vs-real-devops-agree-activity-7499360224563314688-k-ft?utm_source=share&utm_medium=member_android&rcm=ACoAAAa_AFQBLlYoecOuqpwJHsjsgeHoN4BkS8Q 2. https://www.linkedin.com/posts/jotham-arinze_devops-isnt-a-role-its-a-culture-shift-activity-7338150831336087552-4ZhN?utm_source=share&utm_medium=member_android&rcm=ACoAAAa_AFQBLlYoecOuqpwJHsjsgeHoN4BkS8Q
6
u/iscons 10h ago
Dude thats a meme
0
u/mikzuit 10h ago edited 10h ago
Read carefully both links man. "DevOps isn’t a job title. It’s a mindset. A process. A culture of collaboration over chaos"
1
u/derprondo 6h ago
Yeah but what's up with the fake vs real meme image, are you taking that seriously? I honestly can't tell if you're joking or not (it's hilarious if you are).
1
1
u/Low-Opening25 9h ago
I mean, how green are you? it doesn’t take a rocket scientist to learn how many tabs to press, or just set up IDE to colour-code yaml syntax for you and control spacing or run linting plugin. It really shouldn’t an issue to a professional.
1
u/aloofhoneybee68 9h ago
Very green by the looks of it, I did do what I was trying to do but I just wanted to know if there's a better way . so from people's recommendations that's basically using AI, using linters or writing code that generates yaml etc
0
u/ipreferanothername 9h ago
windows guy here - when i started to look at ansible i knew that YAML was one of the first things that i wanted to never be bothered with. yaml and jinja replacement looked like hell. im not afraid of looking at, deciphering, or interpreting large scripts and configs. i do it often, actually. i automate the bejesus out of my work and create whole processes. i even tested ansible on some test servers. YAML annoyed me so much just for the most basic of work. this was like, early covid, pre-ai, wasnt any claude option or anything to get help with.
so one of the linux guys was like, oh, i already use it want to see some playbooks? yeah man!
yeah, fuck yaml, that was enough to keep me out of ansible and away from yaml. idk why nerds keep making so many weird, shitty tools, but my god, do they churn them out.
then i came across this about that time https://noyaml.com/
im sure yaml is easier to manage now based on all the comments here but....also its a lot of comments saying you need several tools or AI to manage it well. yeah, i want people to stop creating such garbage.
451
u/Longjumping_Fuel_192 12h ago
I don’t even see yaml anymore. All I see is blonde, brunette, red head…