Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios_l2_interface - MODULE FAILURE #39011

Closed
mrlesmithjr opened this issue Apr 19, 2018 · 15 comments · Fixed by #39658
Closed

ios_l2_interface - MODULE FAILURE #39011

mrlesmithjr opened this issue Apr 19, 2018 · 15 comments · Fixed by #39658
Assignees
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cisco Cisco technologies ios Cisco IOS community module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team.
Milestone

Comments

@mrlesmithjr
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ios_l2_interface

ANSIBLE VERSION
ansible 2.5.0
  config file = None
  configured module search path = [u'/Users/larry/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Mar 10 2018, 00:01:04) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
CONFIGURATION

None

OS / ENVIRONMENT

I am using macOS and managing Cisco IOS 3750G devices.

SUMMARY

When using this module I keep getting the following error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: switch01#
failed: [switch01] (item={'value': {u'description': u'unconfigured', u'enabled': True, u'state': u'present', u'l2': {u'access_vlan': 1, u'state': u'unconfigured', u'mode': u'access'}, u'l3': {u'state': u'absent', u'ipv4': []}, u'speed': u'auto'}, 'key': u'GigabitEthernet1/0/4'}) => {"changed": false, "item": {"key": "GigabitEthernet1/0/4", "value": {"description": "unconfigured", "enabled": true, "l2": {"access_vlan": 1, "mode": "access", "state": "unconfigured"}, "l3": {"ipv4": [], "state": "absent"}, "speed": "auto", "state": "present"}}, "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_kQ6hf0/ansible_module_ios_l2_interface.py\", line 488, in <module>\n    main()\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_kQ6hf0/ansible_module_ios_l2_interface.py\", line 420, in main\n    if interface_is_portchannel(name, module):\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_kQ6hf0/ansible_module_ios_l2_interface.py\", line 149, in interface_is_portchannel\n    config = get_config(module, flags=[' | section interface'])\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_kQ6hf0/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py\", line 117, in get_config\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_kQ6hf0/ansible_modlib.zip/ansible/module_utils/connection.py\", line 146, in __rpc__\nansible.module_utils.connection.ConnectionError: show running-config  | section interface\r\n                                ^\r\n% Invalid input detected at '^' marker.\r\n\r\nswitch01#\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
STEPS TO REPRODUCE

The following repo has all of the relevant group_vars and playbook

EXPECTED RESULTS

The expected results should be that the l2 interfaces are managed appropriately without failures.

ACTUAL RESULTS
ansible-playbook 2.5.0
  config file = None
  configured module search path = [u'/Users/larry/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 2.7.14 (default, Mar 10 2018, 00:01:04) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
No config file found; using defaults
setting up inventory plugins
Parsed /Users/larry/Git_Projects/Personal/GitHub/mrlesmithjr/ansible-cisco-ios-demo/hosts.inv inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: playbook.yml ***********************************************************************************************************************************************************
1 plays in playbook.yml

PLAY [Managing Cisco IOS Devices] ************************************************************************************************************************************************
META: ran handlers

TASK [Managing L2 Interfaces] ****************************************************************************************************************************************************
task path: /Users/larry/Git_Projects/Personal/GitHub/mrlesmithjr/ansible-cisco-ios-demo/playbook.yml:36
<10.10.10.3> attempting to start connection
<10.10.10.3> using connection plugin network_cli
<10.10.10.3> local domain socket does not exist, starting it
<10.10.10.3> control socket path is /Users/larry/.ansible/pc/386c9c18f0
<10.10.10.3> <10.10.10.3> ESTABLISH CONNECTION FOR USER: admin on PORT 22 TO 10.10.10.3
<10.10.10.3> <10.10.10.3> ssh connection done, setting terminal
<10.10.10.3> <10.10.10.3> loaded terminal plugin for network_os ios
<10.10.10.3> <10.10.10.3> loaded cliconf plugin for network_os ios
<10.10.10.3> <10.10.10.3> firing event: on_open_shell()
<10.10.10.3> <10.10.10.3> firing event: on_become
<10.10.10.3> <10.10.10.3> ssh connection has completed successfully
<10.10.10.3> connection to remote device started successfully
<10.10.10.3> local domain socket listeners started successfully
<10.10.10.3>
<10.10.10.3> local domain socket path is /Users/larry/.ansible/pc/386c9c18f0
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/network/ios/ios_l2_interface.py
<10.10.10.3> ESTABLISH LOCAL CONNECTION FOR USER: larry
<10.10.10.3> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.10.10.3> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540 `" && echo ansible-tmp-1524140293.77-146360030393540="` echo /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540 `" ) && sleep 0'
<10.10.10.3> PUT /Users/larry/.ansible/tmp/ansible-local-7208okODAK/tmpTJHLZC TO /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540/ios_l2_interface.py
<10.10.10.3> EXEC /bin/sh -c 'chmod u+x /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540/ /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540/ios_l2_interface.py && sleep 0'
<10.10.10.3> EXEC /bin/sh -c '/usr/bin/python /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540/ios_l2_interface.py && sleep 0'
<10.10.10.3> EXEC /bin/sh -c 'rm -f -r /Users/larry/.ansible/tmp/ansible-tmp-1524140293.77-146360030393540/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py", line 488, in <module>
    main()
  File "/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py", line 420, in main
    if interface_is_portchannel(name, module):
  File "/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py", line 149, in interface_is_portchannel
    config = get_config(module, flags=[' | section interface'])
  File "/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py", line 117, in get_config
  File "/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_modlib.zip/ansible/module_utils/connection.py", line 146, in __rpc__
ansible.module_utils.connection.ConnectionError: show running-config  | section interface
                                ^
% Invalid input detected at '^' marker.

switch01#

fatal: [switch01]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py\", line 488, in <module>\n    main()\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py\", line 420, in main\n    if interface_is_portchannel(name, module):\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_module_ios_l2_interface.py\", line 149, in interface_is_portchannel\n    config = get_config(module, flags=[' | section interface'])\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py\", line 117, in get_config\n  File \"/var/folders/sn/4yyvc32d5gzf35hdwqmfx73m0000gn/T/ansible_jDfz77/ansible_modlib.zip/ansible/module_utils/connection.py\", line 146, in __rpc__\nansible.module_utils.connection.ConnectionError: show running-config  | section interface\r\n                                ^\r\n% Invalid input detected at '^' marker.\r\n\r\nswitch01#\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 1
}
	to retry, use: --limit @/Users/larry/Git_Projects/Personal/GitHub/mrlesmithjr/ansible-cisco-ios-demo/playbook.retry

PLAY RECAP ***********************************************************************************************************************************************************************
switch01                   : ok=0    changed=0    unreachable=0    failed=1
@ansibot
Copy link
Contributor

ansibot commented Apr 19, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Apr 19, 2018

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team. labels Apr 19, 2018
@mrlesmithjr
Copy link
Contributor Author

Looks like the issue exists here show running-config | section interface. That specific command does not exist on my 3750G switch.

switch01#show running-config | ?
  append    Append redirected output to URL (URLs supporting append operation only)
  begin     Begin with the line that matches
  count     Count number of lines which match regexp
  exclude   Exclude lines that match
  format    Format the output using the specified spec file
  include   Include lines that match
  redirect  Redirect output to URL
  tee       Copy output to URL

@trishnaguha
Copy link
Member

Looks like older devices do not support section but include. section needs to be changed to include.

@mrlesmithjr
Copy link
Contributor Author

That is exactly what I was going to recommend.

@mrlesmithjr
Copy link
Contributor Author

And to confirm, I have pulled this module locally and changed section to include and it ran successfully.

@mrlesmithjr
Copy link
Contributor Author

Switch version:

switch01#show version
Cisco IOS Software, C3750 Software (C3750-IPSERVICESK9-M), Version 12.2(55)SE12, RELEASE SOFTWARE (fc2)

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Apr 19, 2018
@mrlesmithjr
Copy link
Contributor Author

Same thing for ios_l3_interface module.

@mrlesmithjr
Copy link
Contributor Author

Looks like we probably need to add additional logic to this PR #39025

@mrlesmithjr
Copy link
Contributor Author

mrlesmithjr commented Apr 19, 2018

Thinking this might be the correct way (#39025):

def interface_is_portchannel(name, module):
    if get_interface_type(name) == 'ethernet':
        config = run_commands(
            module, ['show run interface {0}'.format(name)])[0]
        if 'channel group' in config:
            return True
        elif 'channel-group' in config:
            return True

    return False

For example if I have 3 interfaces configured as below on the switch:

interface GigabitEthernet1/0/1
 description unconfigured
 switchport mode access
!
interface GigabitEthernet1/0/4
 description unconfigured
 switchport mode access
 spanning-tree portfast
!
interface GigabitEthernet1/0/24
 description NAS02
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 24,101,102,127-130,201
 switchport mode access
 channel-protocol lacp
 channel-group 2 mode active
 spanning-tree portfast trunk
!

With the above module code change when ran using Ansible results in the following:

failed: [switch01] (item={'value': {u'enabled': True, u'state': u'present', u'l2': {u'access_vlan': 1, u'state': u'unconfigured', u'mode': u'access'}, u'description': u'unconfigured', u'speed': u'auto'}, 'key': u'GigabitEthernet1/0/24'}) => {"changed": false, "item": {"key": "GigabitEthernet1/0/24", "value": {"description": "unconfigured", "enabled": true, "l2": {"access_vlan": 1, "mode": "access", "state": "unconfigured"}, "speed": "auto", "state": "present"}}, "msg": "Cannot change L2 config on physical \nport because it is in a portchannel. \nYou should update the portchannel config."}
ok: [switch01] => (item={'value': {u'description': u'unconfigured', u'enabled': True, u'state': u'present', u'l2': {u'access_vlan': 1, u'state': u'unconfigured', u'mode': u'access'}, u'l3': {u'state': u'absent', u'ipv4': []}, u'speed': u'auto'}, 'key': u'GigabitEthernet1/0/1'})
ok: [switch01] => (item={'value': {u'description': u'unconfigured', u'enabled': True, u'state': u'present', u'l2': {u'access_vlan': 1, u'state': u'unconfigured', u'mode': u'access'}, u'l3': {u'state': u'absent', u'ipv4': []}, u'speed': u'auto'}, 'key': u'GigabitEthernet1/0/4'})

@LukeDRussell
Copy link
Contributor

Not sure just changing section to include is going to be enough. It doesn't produce very interesting information:

2960#show runn | include interface
ip tftp source-interface Vlan1
interface FastEthernet0/1
interface FastEthernet0/2
interface FastEthernet0/3
interface FastEthernet0/4
interface FastEthernet0/5
interface FastEthernet0/6
interface FastEthernet0/7
interface FastEthernet0/8
interface FastEthernet0/9
interface FastEthernet0/10
interface FastEthernet0/11
interface FastEthernet0/12
interface FastEthernet0/13
interface FastEthernet0/14
interface FastEthernet0/15
interface FastEthernet0/16
interface FastEthernet0/17
interface FastEthernet0/18
interface FastEthernet0/19
interface FastEthernet0/20
interface FastEthernet0/21
interface FastEthernet0/22
interface FastEthernet0/23
interface FastEthernet0/24
interface GigabitEthernet0/1
interface GigabitEthernet0/2
interface Vlan1
ip tacacs source-interface Vlan1
logging source-interface Vlan1

However, show run interface xxx is a bit better, and works on every platform I know of:

2960#show running-config interface f0/1
Building configuration...

Current configuration : 95 bytes
!
interface FastEthernet0/1
 description Some Wall outlet
 spanning-tree portfast
end

@LukeDRussell
Copy link
Contributor

Ah, on second look your most recent post is using show run interface.

Apologies.

@mrlesmithjr
Copy link
Contributor Author

@lukerussell No worries man. I noticed the same thing after going that route earlier this morning. Running through several scenarios currently and this module seems to cause me a bit of grief but nothing we cannot get around.

@trishnaguha
Copy link
Member

@mrlesmithjr @lukerussell The PR #39658 fixes the issue. Can you try the fix and let us know?
Thanks!

@trishnaguha trishnaguha moved this from In progress to In Review in zzz NOT USED: Networking Bugs May 3, 2018
@trishnaguha trishnaguha added the needs_info This issue requires further information. Please answer any outstanding questions. label May 3, 2018
@trishnaguha trishnaguha moved this from In Review to Need CP into 2.5.3 in zzz NOT USED: Networking Bugs May 4, 2018
@trishnaguha trishnaguha moved this from Need CP into 2.5.3 to In Review in zzz NOT USED: Networking Bugs May 4, 2018
@trishnaguha trishnaguha moved this from In Review to Need CP into 2.5.3 in zzz NOT USED: Networking Bugs May 4, 2018
@LukeDRussell
Copy link
Contributor

Hi, sorry I haven’t checked this, I don’t have any older devices in my lab and I’ve been away from work for the week.

@trishnaguha trishnaguha moved this from Need CP into 2.5.3 to Done in zzz NOT USED: Networking Bugs May 8, 2018
@dagwieers dagwieers added ios Cisco IOS community cisco Cisco technologies labels Feb 23, 2019
@ansible ansible locked and limited conversation to collaborators May 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cisco Cisco technologies ios Cisco IOS community module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

6 participants