CiscoDevNet / ansible-dcnm

Apache License 2.0
45 stars 36 forks source link

dcnm_interface: for routed interface, specifying mtu generates ansible conversion error #151

Closed gve-vse-tim closed 2 years ago

gve-vse-tim commented 2 years ago

The DCNM Ansible dcnm_interface module documentation says that, for the 'eth' profile, the MTU attribute is supposed to be a string. However, when I do specify the MTU attribute for a routed interface (in the example below), I get an Ansible error regarding conversion to 'int'. While the example below indicated mtu 'default', I have verified the same error gets thrown for mtu 'jumbo' (which is supposed to be the default value).

Not specifying mtu at all works just fine (and of course defaults to jumbo: 9216). The example was tested against the dCloud VXLAN Multisite environment (not following the VXLAN script though... just giving you a standard environment upon which to verify it).

Sample Ansible:

- hosts: dcnm
  gather_facts: false
  connection: ansible.netcommon.httpapi

  collections:
    - cisco.dcnm

  vars:
    # Need to extend timeouts because discovery process is slow
    ansible_command_timeout: 1800
    ansible_connect_timeout: 1800

    switch_username: "{{ lookup('env', 'SWITCH_USER') }}"
    switch_password: "{{ lookup('env', 'SWITCH_PASS') }}"

  tasks:
    - name: Create L3 Routed Link between Core and Aggregate
      dcnm_interface:
        fabric: "{{ site1.fabric_name }}"
        check_deploy: yes
        state: merged
        config:
          - name: Ethernet1/2
            deploy: yes
            switch:
              - "{{ site1.spine1_ip }}"
            type: eth
            profile:
              admin_state: yes
              mode: "routed"
              mtu: "default"
              ipv4_addr: 192.168.0.1
              ipv4_mask_len: 30

Output of the error:

PLAY [dcnm] *********************************************************************************************************************************************************************

TASK [Create L3 Routed Link between Core and Aggregate] *************************************************************************************************************************
fatal: [dcloud_dcnm]: FAILED! => {"changed": false, "module_stderr": "<class 'ansible.parsing.yaml.objects.AnsibleUnicode'> cannot be converted to an int", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}

PLAY RECAP **********************************************************************************************************************************************************************
dcloud_dcnm                : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
gve-vse-tim commented 2 years ago

The docs say the only two options are "default" and "jumbo" but specifying strings representing actual MTU sizes ("1500" and "9216") does in fact work. So, in short, could easily be simply a doc bug.

praveenramoorthy commented 2 years ago

@gve-vse-tim, Thanks for raising this issue. You are right, this is a documentation issue, for truck and access mtu should be string and for routed interface it should be integer. Will fix it.