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.
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 %}
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.
I checked, the user-data file in /var/lib/cloud/seed/nocloud-net/ is exactly as it is in the profile, so that seems to pass correctly.
If I issue: cloud-init query -f {{distro}} - I get the correct metadata variable of “debian”.
If I issue: cloud-init devel render /var/lib/cloud/seed/nocloud-net/user-data -d
it renders the entire user-data config, not just the jinja template variable like I normally see. It just seems to ignore the variable.
LXD is cloud provider. Containers are hosted on-prem. Log collection attached.
Thank you
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.
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 %}
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.
I checked, the user-data file in /var/lib/ cloud/seed/ nocloud- net/ is exactly as it is in the profile, so that seems to pass correctly.
If I issue: cloud-init query -f {{distro}} - I get the correct metadata variable of “debian”.
If I issue: cloud-init devel render /var/lib/ cloud/seed/ nocloud- net/user- data -d
it renders the entire user-data config, not just the jinja template variable like I normally see. It just seems to ignore the variable.
LXD is cloud provider. Containers are hosted on-prem. Log collection attached.
Thank you