QuestionQ88

VerifiedNetwork Automation Foundation

An engineer needs to generate access-port interface configurations from inventory with a Jinja2 template. The engineer must use loops, a shutdown-state conditional, and filters that supply sensible defaults for missing descriptions. Drag the code snippets into the boxes to construct the artifact. Not every option is used.

Drag & Drop
{%- for iface in  %}
interface {{ iface.name }}
description {{ iface. | ('UNSET') }}
switchport mode access
switchport access vlan {{ iface. }}
{% if iface.shutdown %}shutdown{% else %}no shutdown{% endif %}
!
{%- endfor %}
Explanation

The loop must iterate over the inventory's interface collection. Each interface uses its desc attribute, and Jinja2's default('UNSET') filter supplies the fallback when that value is undefined. The access VLAN is read from the interface's vlan attribute.

Community Discussion

No comments yet. Be the first to start the discussion!