Nested varibbles and defined

Hi. Right now defined only works with up-to-second-last defined variables. That is, if var1 exists as a map but var1.var2 doesn’t, this works and will print DEFAULTED: var1.var2 | default('DEFAULTED'). But for the same var1 this results in an error: var1.var2.var3 | default('FAILS').

So I was reading the docs how to either pass extra params to default to allow to check/early return over null variables (like the var1.var2 above) or write a new function/jinja2 filter that allows that.

So far I was not able to do it. All I could google was actions/lookup/callback/vars plugins. Any ideas on this is ver welcome!

Thanks a lot!

need to set default at every level that might be undefined.

(var1|default({})).(var2|default({})).var3 | default(‘FAILS’)