{% if params.l2.mode == "access" %}
 switchport mode access
 {% if (params.l2.access_vlan and params.l2.access_vlan != 1) %}
 switchport access vlan {{ params.l2.access_vlan }}
 {% endif %}
{% elif params.l2.mode == "trunk" %}
 switchport mode trunk
 {% if (params.l2.native_vlan and params.l2.native_vlan != 1) %}
 switchport trunk native vlan {{ params.l2.native_vlan }} 
 {% endif %}
 {% if params.l2.allowed_vlans %}
 switchport trunk allowed vlan {% for vlan_range in params.l2.allowed_vlans %}{{ vlan_range }}{% if not loop.last %},{% endif %}{% endfor %}

 {% endif %}
{% endif %}