Replies: 4 comments 3 replies
-
Hi there! This is an interesting idea. I'm curious (and I haven't tested this) but since you can run a python interpreter within a playbook is there much difference? You would just need to import the json library and load the json string I think it would look something like this:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for answering. Yes, calling python like this would work, you don't even need json and can directly use the dict:
But I think using jello has several advantages:
I think especially the last point is really helpful. Consider for example this where I need to regroup a complex data structure:
and the switch-conifg.j2 template then uses the code like this:
You could of course also create a new datastructure with a call to python before and use that in the template. But I think using jello here is more elegant, shorter and faster. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your input on this. I am subscribed to the Ansible development mailing list, which is the channel I used to develop the |
Beta Was this translation helpful? Give feedback.
-
Nice idea - like a debug mode with |
Beta Was this translation helpful? Give feedback.
-
Hi,
I thought it would be helpful to have jello available as filter in Ansible.
Why you may ask?
I find the jmespath filter syntax that is available with
community.general.json_query
quite limited (for example in comparison tojc
) and still as complicated as jc.So I could create custom Ansible filter plugins instead. Yes, I've been doing that. But they have several downsides:
filter_plugins/
). This makes reading the code flow in a playbook more difficult, you have to jump between the filesI think jello would be a nice fit to help with that.
Here is a short task snippet how using it could look like:
Here is the code I used to implement this:
jello.py.txt
Do you think this is a good idea?
Does this implementation make sense to you or think it could be improved?
I'm thinking about two improvements:
jellex
: I'm thinking about an option that automatically dumps the input and output data structures of jello to disk as json files. This would allow you to easily load them with jellex to work on the code. Unfortunately I haven't found a way yet to get proper filenames that represent the current task or step within the Ansible playbook.Beta Was this translation helpful? Give feedback.
All reactions