Re:Red Hat is buying Ansible
by justingood on Friday October 16, 2015 @11:37AM
(#10399998)
I'd agree that jinja2 has a perfectly fine way of handling loops, but the problem is that functionality only works in Ansible template files.
The Ansible playbook can only make use jinja2 filters to act on variables:
https://docs.ansible.com/ansible/playbooks_filters.html
Oh no disagreement there. I was just disagreeing with the GPs disparagement of jinja2, which is a limitation of how Ansible was implemented and has absolutely nothing to do with jinja2.
Ansible is great stuff, but some of those decisions were quite weird.
Jinja is great as a templating language. I find yaml by itself to be clean and readable. Cram all of it in to the same soup, mix in the global variables, and it quickly turns into a nightmare. It takes what's already a problem in a dynamically typed language and amplifies it.
This comment makes pretty much no sense at all. Example of a loop in jinja2:
{% for item in ("one", "two", "three") %}
{% endfor %}The logic is pure python minus perhaps setting variables ie:
{% set name = "dorfsmay" %}
{% if name == "dorfsmay" or name.startswith("dorfs") %}
{% endif %}