Hacker News new | ask | show | jobs
by dorfsmay 3897 days ago
I think when ansible started it wasn't obvious that logic (loops, conditional etc...) would be needed eventually. By the time it became obvious it was going to be required, it was too late to change.

Using jinja2 for markup compounded the issue in my opinion, as it has no loops and logic is less than obvious (compared to mako for example).

Still I find its agentless model, the idempotent model, being able to use it on machines where you don't have root access etc... gives it a place that nobody had fulfilled.

2 comments

""" Using jinja2 for markup compounded the issue in my opinion, as it has no loops and logic is less than obvious """

This comment makes pretty much no sense at all. Example of a loop in jinja2:

{% for item in ("one", "two", "three") %}

    item is {{ item }}
{% endfor %}

The logic is pure python minus perhaps setting variables ie:

{% set name = "dorfsmay" %}

{% if name == "dorfsmay" or name.startswith("dorfs") %}

    You're spreading FUD about jinja2
{% endif %}
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.
{% for x in y %}

isn't a loop?