ansible-collections / junipernetworks.junos

Ansible Network Collection for Juniper JunOS
GNU General Public License v3.0
82 stars 63 forks source link

junos_l2_interface with trunk mode doesn't work on pre-ELS switches #395

Open jcgruenhage opened 1 year ago

jcgruenhage commented 1 year ago
SUMMARY

native-vlan-id goes inside unit 0 family ethernet-switching on pre-ELS switches, but setting enhanced_layer: false does not affect that part. As a result, untagged traffic is dropped instead of using the configured native vlan.

ISSUE TYPE
COMPONENT NAME

junos_l2_interface

ANSIBLE VERSION
ansible [core 2.14.3]
  config file = None
  configured module search path = ['/home/jcgruenhage/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/jcgruenhage/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Feb  8 2023, 14:30:35) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /usr/lib/python3.11/site-packages/ansible_collections
Collection            Version
--------------------- -------
junipernetworks.junos 4.1.0  

# /home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible_collections
Collection            Version
--------------------- -------
junipernetworks.junos 5.0.0  
CONFIGURATION
ANSIBLE_NOCOWS(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = True
COLLECTIONS_PATHS(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = ['/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage']
CONFIG_FILE() = /home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg
DEFAULT_HOST_LIST(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = ['/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/inventory.yml']
DEFAULT_JINJA2_EXTENSIONS(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = jinja2.ext.do
DEFAULT_ROLES_PATH(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = ['/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/roles']
DEFAULT_VAULT_PASSWORD_FILE(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = /home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/vaultpass.sh
DIFF_CONTEXT(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = 5
RETRY_FILES_ENABLED(/home/jcgruenhage/dev/jcg.re/jcgruenhage/ansible-jcgruenhage/ansible.cfg) = False
OS / ENVIRONMENT

Host OS is Void Linux, but that shouldn't be relevant. Target info:

Model: ex3300-48p
Junos: 15.1R5.5
JUNOS EX  Software Suite [15.1R5.5]
JUNOS FIPS mode utilities [15.1R5.5]
JUNOS Online Documentation [15.1R5.5]
JUNOS EX 3300 Software Suite [15.1R5.5]
JUNOS Web Management Platform Package [15.1R5.5]
STEPS TO REPRODUCE
- name: Configure VLANs
  hosts: ex3300
  connection: ansible.netcommon.netconf
  gather_facts: false
  tasks:
    - name: Create VLANs
      junipernetworks.junos.junos_vlans:
        config:
          - name: ka23
            vlan_id: 1
          - name: freifunk
            vlan_id: 255
          - name: iot
            vlan_id: 4
        state: replaced
    - name: Set interfaces to use VLANs
      junipernetworks.junos.junos_l2_interfaces:
        config:
          - name: ge-0/0/0
            enhanced_layer: false
            trunk:
              allowed_vlans: [iot, freifunk]
              native_vlan: 1
        state: replaced
EXPECTED RESULTS

The expected config that should be generated:

ge-0/0/0 {
    unit 0 {
        family ethernet-switching {
            port-mode trunk;
            vlan {
                members [ iot freifunk ];
            }
            native-vlan-id 1;
        }
    }
}
ACTUAL RESULTS

The config that is generated instead:

ge-0/0/0 {
    ##
    ## Warning: statement ignored: unsupported platform (ex3300-48p)
    ## Warning: native-vlan-id can be specified with flexible-vlan-tagging mode or with interface-mode trunk
    ##
    native-vlan-id 1;
    unit 0 {
        family ethernet-switching {
            port-mode trunk;
            vlan {
                members [ iot freifunk ];
            }
        }
    }
}
jcgruenhage commented 1 year ago

In case anyone else runs into this, I've been able to work around this by using the junos_config module:

    - name: Set interfaces to use VLANs
      junipernetworks.junos.junos_config:
        lines:
          - set interfaces {{ item.interface }} unit 0 family ethernet-switching port-mode trunk
          - set interfaces {{ item.interface }} unit 0 family ethernet-switching native-vlan-id {{ item.native_vlan }}
          - set interfaces {{ item.interface }} unit 0 family ethernet-switching vlan members [ {{ item.vlan_members | join(' ') }} ]
      loop:
        - interface: ge-0/0/0
          native_vlan: 1
          vlan_members: [iot, freifunk]