jinja2

Ansible Jinja2 Conditional Ternary service_type with expose_service

Introduction In Kubernetes-related automation, it’s common to toggle between NodePort and ClusterIP depending on whether a service should be exposed or not.

Continue reading

Ansible Ternary Operator in Jinja2 Templates

Introduction Writing efficient conditional logic in Ansible often means leveraging Jinja2 templating.

Continue reading

Filtering Data in Ansible: selectattr and map(attribute)

🎯 Filtering Data in Ansible: selectattr and map(attribute) When working with lists of dictionaries in Ansible, filtering and extracting specific values is a common requirement.

Continue reading

Adding Commas Between Elements in Jinja2

Introduction Creating a comma-separated list is a common task in templating, but ensuring no trailing comma appears after the last element can be tricky.

Continue reading

Generate Clean YAML Output from Ansible Facts

Ansible is a powerful tool for automating tasks, but when working with dynamically generated data, such as Ansible facts, it can sometimes be tricky to produce clean, well-formatted output.

Continue reading