Ansible Skills - The default(omit) feature

I put together a quick video on one of my favorite (and, in my opinion, underrated) Ansible features: default(omit).

It’s a simple trick that lets you completely omit a module parameter when a variable isn’t defined, instead of passing an empty value. I use it all the time to make playbooks more reusable and avoid extra when statements or duplicate tasks.

The video is under 3 minutes and includes a simple localhost demo using the copy module to show how it works.

I’m curious, what’s your favorite “hidden gem” in Ansible that more people should know about? I’m looking for ideas for future shorts.

In my opinion, whereby videos for first users and beginners are good to gain an overview and start learning fast, it will become a disadvantage later on. One can not search in it or do copy and paste … Would it be OK for you to add some writings, the text and example playbook from the video to your post?

Apart from that and if someone is interested, the documentation has also some information about Making variables optional.

That is great feedback, I am putting my playbooks and some descriptions on Github to make this easy for folks to read or cut and paste: ansible-tips/tips/default-omit at main · ansible-tmm/ansible-tips · GitHub

Do you think this would work?

Sure, that’s one way to go. Looks good relady.