This may be more of a cloud-init bug, but I thought I would ask if anyone has run into this issue.
I run lxd profiles with cloud-init (#cloud-config) configurations, and I use jinja2 templating (## template: jinja) so I can use one profile that I can apply to many distros. It works great, except on some images I notice ignore the jinja2 template directives.
When I launch a new debian/11/cloud image, I noticed it does not adhere to the jinja2 template.
My profile begins like:
config:
user.user-data: |
## template: jinja
#cloud-config
{% if distro == 'centos' or 'rocky' -%}
users:
~Do some stuff.....
{%- endif %}
{% if distro == 'debian' or 'ubuntu' -%}
users:
~Do some stuff.....
{%- endif %}
On the debian/11/cloud image, it just runs the first cloud-init block below user.user-data: |
and ignores the jinja directives.
The image has cloud-init 20.4.1, and has the jinja2 engine installed. So I don’t understand why it would not adhere to the jinja directives in the profile like all other distros do.
As a work around, I just have a rudimentary cloud-init config in a separate profile that I assign to these debian containers.
When I query cloud-init with:
cloud-init query --format "$(sudo cloud-init query userdata)"
I see ALL cloud-init settings apply, even ones for other distros, as if it just runs all directives.
If anyone has seen this, and knows the fix, please share.
Thanks