Interview Prep/Ansible/Jinja2, Conditionals and Loops

Which filters do you use every day?

BeginnerConceptJinja2, Conditionals and Loops
Answer
"{{ x | default('fallback') }}"
"{{ names | join(',') }}"
"{{ name | upper }}  {{ name | lower }}  {{ s | trim }}"
"{{ list | length }}"
"{{ data | to_json }}"  "{{ data | to_nice_yaml }}"
"{{ path | basename }}  {{ path | dirname }}"
"{{ pw | password_hash('sha512') }}"
"{{ value | int }}  {{ flag | bool }}"
"{{ secret | b64encode }}"

Run ansible-doc -t filter -l to list them. Anything not built in is available in collections such as ansible.utils and community.general.

All Ansible questions Roadmap: Ansible

More on Jinja2, Conditionals and Loops