diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index a3ce24eb8ac..b706ca8f2b2 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -514,7 +514,12 @@ def map_config_to_obj(want, module): intf_type = get_interface_type(w['name']) if intf_type in ['portchannel', 'ethernet']: - if not interface_table.get('eth_mode'): + mode = interface_table.get('eth_mode') + if mode in ('access', 'trunk', 'dot1q-tunnel'): + obj['mode'] = 'layer2' + elif mode in ('routed', 'layer3'): + obj['mode'] = 'layer3' + else: obj['mode'] = 'layer3' if intf_type == 'ethernet': @@ -524,11 +529,6 @@ def map_config_to_obj(want, module): obj['mtu'] = interface_table.get('eth_mtu') obj['duplex'] = interface_table.get('eth_duplex') speed = interface_table.get('eth_speed') - mode = interface_table.get('eth_mode') - if mode in ('access', 'trunk'): - obj['mode'] = 'layer2' - elif mode in ('routed', 'layer3'): - obj['mode'] = 'layer3' command = 'show run interface {0}'.format(obj['name']) body = execute_show_command(command, module)[0] @@ -557,6 +557,7 @@ def map_config_to_obj(want, module): 'nxapibug')) obj['description'] = str(attributes.get('description', 'nxapi_bug')) + obj['mtu'] = interface_table.get('svi_mtu') command = 'show run interface {0}'.format(obj['name']) body = execute_show_command(command, module)[0] @@ -578,11 +579,7 @@ def map_config_to_obj(want, module): obj['name'] = normalize_interface(interface_table.get('interface')) obj['admin_state'] = interface_table.get('admin_state') obj['description'] = interface_table.get('desc') - mode = interface_table.get('eth_mode') - if mode == 'access': - obj['mode'] = 'layer2' - else: - obj['mode'] = 'layer3' + obj['mtu'] = interface_table.get('eth_mtu') objs.append(obj) diff --git a/lib/ansible/modules/network/nxos/nxos_linkagg.py b/lib/ansible/modules/network/nxos/nxos_linkagg.py index 0a0a41c1f70..2744f50e23c 100644 --- a/lib/ansible/modules/network/nxos/nxos_linkagg.py +++ b/lib/ansible/modules/network/nxos/nxos_linkagg.py @@ -291,9 +291,9 @@ def parse_mode(module, m): flags = ['| section interface.{0}'.format(m)] config = get_config(module, flags=flags) - match = re.search(r'mode (\S+)', config, re.M) + match = re.search(r'channel-group [0-9]+ (force )?mode (\S+)', config, re.M) if match: - mode = match.group(1) + mode = match.group(2) return mode