Skip to content

Commit 5fcf1d0

Browse files
gmulocClausHolbechAristaShivani-gslab
authored
Fix(eos_designs): Address template values being None for custom template for ansible-core >= 2.19 (#6663)
Co-authored-by: Claus Holbech <holbech@arista.com> Co-authored-by: Shivani-gslab <145646625+Shivani-gslab@users.noreply.github.com>
1 parent ef88cf2 commit 5fcf1d0

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{#
2+
This template is used to test the output of custom template when the generated output is empty.
3+
The behavior changed between ansible-core <2.19 and >=2.19
4+
#}
5+
{% if not_defined is arista.avd.defined %}
6+
{% endif %}
7+

ansible_collections/arista/avd/extensions/molecule/ansible_only/inventory/group_vars/CUSTOM_TEMPLATES_SPINES.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ spine:
1212
- name: custom-templates-spine1
1313
id: 1
1414
mgmt_ip: 192.168.200.101/24
15+
16+
# Test custom template that produces empty output which behaves
17+
# differently in ansible-core <2.19 and ansible-core >=2.19
18+
eos_designs_custom_templates:
19+
- template: custom_templates/empty.j2
20+
options:
21+
list_merge: append_rp
22+
strip_empty_keys: false

ansible_collections/arista/avd/plugins/action/eos_designs_structured_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def run(self, tmp: Any = None, task_vars: dict | None = None) -> dict:
125125
# Here we parse the template, expecting the result to be a YAML formatted string
126126
template_result = templater(template, template_vars, self.templar)
127127

128+
# Skip if template result is None or empty string
129+
if not template_result:
130+
continue
131+
128132
# Load data from the template result.
129133
template_result_data = yaml.safe_load(template_result)
130134

0 commit comments

Comments
 (0)