Filters: default, join & upper
Transform values inside templates.
Filters: default, join & upper is a free Ansible Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What a Filter Does
A filter transforms a value on its way to output. You apply one with a pipe, reading left to right like a tiny pipeline. 🧰
{{ name | upper }}The upper Filter
The upper filter shouts a string into all capitals, while lower does the opposite. Great for normalizing text.
{{ region | upper }}
{{ region | lower }}The default Filter
Use default to supply a fallback when a variable is undefined, so the render never crashes on a missing value.
listen {{ http_port | default(80) }};default for Empty Values
Pass true as a second argument to also replace empty strings, not just undefined ones. A stricter fallback.
{{ user | default('admin', true) }}The join Filter
Turn a list into one string with join, choosing the glue between items. Perfect for comma-separated config values.
allowed = {{ ips | join(', ') }}Chaining Filters
Pipe several filters in a row; each feeds the next. Here a list is joined and then forced to lowercase in one expression.
{{ tags | join(',') | lower }}length and Counting
The length filter counts items in a list or characters in a string, handy for sizing pools or loops.
workers = {{ servers | length }}trim and replace
Clean text with trim to drop edge spaces, or replace to swap one substring for another.
{{ path | replace('//', '/') }}Filters for Numbers
Numeric filters help too: int and float convert types, while round shapes a decimal to fixed places.
{{ ('8' | int) * 1024 }}Ansible-Specific Filters
Ansible adds its own filters like to_json and to_nice_yaml for dumping data structures cleanly into files.
{{ config | to_nice_yaml }}Filters Read Left to Right
Order matters in a chain: the value flows through each filter in sequence, so place transforms in the order you need them.
Quick Check
A variable might be undefined and you want a safe fallback value. Which filter handles that?
Recap
You met filters: default for fallbacks, join for lists, upper for text, plus length and chaining. Pipes transform values cleanly. ✨
Frequently asked questions
Is the “Filters: default, join & upper” lesson free?
Yes — the full text of “Filters: default, join & upper” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.
What will I learn in “Filters: default, join & upper”?
Transform values inside templates. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ansible Academy?
No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Filters: default, join & upper” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ansible Academy lesson?
Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The template Module & .j2 Files
- Variables & Expressions in Jinja2
- Loops & if Blocks in Templates
- Filters: default, join & upper