Hacker News new | ask | show | jobs
by PowerBar 2038 days ago
As a long time puppet user, I started forcing myself to use ansible for my homelab so I can learn it's intricacies and limitations.

Recently I had a use-case where I wanted to re-use some data from a defined variable (list of objects) in a second module, but the format had to be different. In python I would have done something like new_var=[{a:i['a'], b:i['b']} for i in old_var], but apparently that is impossible in ansible. The best solution I was able to find after lots of searching was to to pass new_var to a jinja2 template which would render new_var as text, then run that through a json interpreter and set that as new_var. Absolutely rediculous.

It astounds me that a tool BUILT on python lacks any semblance of python's biggest feature, list comprehension.

1 comments

Modules are where the python lives. Really well written, idempotent, and battle tested python.

But "writing" Ansible playbooks is definitely not python. It's its own dsl bastardized between yaml, jinja2 and reserved/special keywords. This is the worst thing I can say about the whole toolkit.

Unfortunately, I'm really productive with it and when I return to work I've written 3+ years ago:

A) It still runs

2) I can read and understand the intent of my playbooks