Skip to content

Tag: jinja2

Ansible write variables into YAML file

I have a specific ansible variable structure that I want to get from the vault into a yaml file on my hosts. Lets assume a structure like this: I need something like a “generic” template to output whatever “secrets” contains at the moment, since the content changes almost completely ba…

Sort dict in jinja2 loop

I’m still learning jinja2 and flask and I’m having a difficulty using dictsort in jinja2. So I’m passing this dict into a jinja2 template: What I want is create a table that is sorted by the value of the key ‘totalpts’. I tried all sort of things and it just doesn’t take to…

Pass variables to Flask’s render_template

I want to pass multiple variables from my Flask view to my Jinja template. Right now, I can only pass one. How do I pass multiple variable when rendering a template? Answer The render_template function takes any number of keyword arguments. Query for each of the things you need in the template, then pass the …