jinja-template doesn't support 'do' extension.
Bug #1962759 reported by
paul bruno
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Medium
|
paul bruno |
Bug Description
example user-data file with jinja
## template: jinja
#!/bin/sh
{% set data_result = [] %}
{% set data_input = [1,2,3] %}
{% for i in data_input %}
{% do data_result.
{% endfor %}
echo results: {{data_result}} >>results.out
The following exception is thrown when using jinja2 'do' statement.
jinja2.
I'm using cloud-init from a 64bitencoded file passed into terraform azure provider custom_data.
To post a comment you must log in.
Thank you for filing this bug and making Ubuntu and cloud-init better.
In investigation on this issue, I can see we don't load the jinja extension `ExprStmtExtension` or "do" extension. ["jinja2. ext.do" ] to our JTemplate in cloudinit. templater.
In testing yesterday, I think we can just provide extensions=
For versions of cloud-init that don't yet have a fix for this, the workaround in the absence of the "do" extension, they can use jinja default filter to return an empty string instead of printing None.
{% set data_result = [] %} append( i)|default( "",True) }}
{% set data_input = [1,2,3] %}
{% for i in data_input %}
{{ data_result.
{% endfor %}
{{data_result}}