Open chadell opened 1 year ago
You can pass multiple filters in one line. Not sure if that is the concern here.
{% raw %}{{ 'device-ssh-creds' | get_secret_by_secret_group_name("password") | encrypt_cisco_type7 }}{% endraw %}
You can pass multiple of the custom function filters in one line too.
username {% raw %}{{ 'device-ssh-creds' | get_secret_by_secret_group_name("username") | encrypt_cisco_type7 }}{% endraw %} password 0 {% raw %}{{ 'device-ssh-creds' | get_secret_by_secret_group_name("password") | encrypt_cisco_type7 }}{% endraw %}
Only seeing the rendering happening 1 time.
Environment
Proposed Functionality
Currently, the config postprocessing feature is simply concatenating functions to manipulate a configuration. These functions can be whatever type of operation, including, but not limited to rendering Jinjat templates. The way it is implemented today if two functions need to do a Jinja template rendering, the rendering happens twice instead of applying both filters into one rendering task. The main issue about this is using nested
{%raw%}
makes it hard to scale.Use Case
The proposed approach would be to keep this generic approach (i.e. concatenating callables) but offer another hook to register filters to be rendered once. Thus, the network automation engineer could add multiple Jinja filters (e.g. the
get_secret_by_secret_group_slug
) and there would render the template once. This reduces the boilerplate code and simplifies the definition of original Jinja template because only one level of{%raw%}
is required.