From 3f31ff71338c32402ca4fba34a96a39fce62af3b Mon Sep 17 00:00:00 2001 From: GeertJohan Date: Tue, 4 Aug 2026 16:42:14 +0200 Subject: [PATCH] use boolean jinja2 template overrides ansible-core 2.19 and later reject non-boolean values in the jinja2 override header, so quoted values like "True" fail with 'TemplateOverrides.trim_blocks must be '. On older ansible versions the header value is parsed with ast.literal_eval and the quotes are part of the header text, so "False" yields the string 'False' rather than the boolean. Jinja2 later uses that value in a boolean context, where a non-empty string counts as enabled, which means the metal.yaml.j2 header effectively behaved as True. The headers are therefore set to the literal booleans that match the current rendering behavior, verified against the existing template golden tests. --- partition/roles/dhcp/templates/dhcpd.hosts.j2 | 2 +- partition/roles/sonic-config/templates/frr.conf.j2 | 2 +- partition/roles/sonic/templates/frr.conf.j2 | 2 +- partition/roles/sonic/templates/metal.yaml.j2 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/partition/roles/dhcp/templates/dhcpd.hosts.j2 b/partition/roles/dhcp/templates/dhcpd.hosts.j2 index b3858e362..a27626f68 100644 --- a/partition/roles/dhcp/templates/dhcpd.hosts.j2 +++ b/partition/roles/dhcp/templates/dhcpd.hosts.j2 @@ -1,4 +1,4 @@ -#jinja2: lstrip_blocks: "True", trim_blocks: "True" +#jinja2: lstrip_blocks: True, trim_blocks: True {% for host in dhcp_static_hosts %} host {{ host.name }} { hardware ethernet {{ host.mac }}; diff --git a/partition/roles/sonic-config/templates/frr.conf.j2 b/partition/roles/sonic-config/templates/frr.conf.j2 index b98a7f83f..69f2428f6 100644 --- a/partition/roles/sonic-config/templates/frr.conf.j2 +++ b/partition/roles/sonic-config/templates/frr.conf.j2 @@ -1,4 +1,4 @@ -#jinja2: lstrip_blocks: "True", trim_blocks: "True" +#jinja2: lstrip_blocks: True, trim_blocks: True frr defaults datacenter hostname {{ inventory_hostname }} ! diff --git a/partition/roles/sonic/templates/frr.conf.j2 b/partition/roles/sonic/templates/frr.conf.j2 index f4cf2fa8b..ee1880873 100644 --- a/partition/roles/sonic/templates/frr.conf.j2 +++ b/partition/roles/sonic/templates/frr.conf.j2 @@ -1,4 +1,4 @@ -#jinja2: lstrip_blocks: "True", trim_blocks: "True" +#jinja2: lstrip_blocks: True, trim_blocks: True frr defaults datacenter hostname {{ inventory_hostname }} ! diff --git a/partition/roles/sonic/templates/metal.yaml.j2 b/partition/roles/sonic/templates/metal.yaml.j2 index 011120173..e28b8a9bb 100644 --- a/partition/roles/sonic/templates/metal.yaml.j2 +++ b/partition/roles/sonic/templates/metal.yaml.j2 @@ -1,4 +1,4 @@ -#jinja2: lstrip_blocks: "False", trim_blocks: "False" +#jinja2: lstrip_blocks: True, trim_blocks: True --- {% set vrfs = [] %} DEVICE_METADATA: