# Buggy code
def execute_show_command(command, module):
    if module.params["transport"] == "cli":
        command += " | json"
    cmds = [command]
    body = run_commands(module, cmds)
    return body


# Traceback (AttributeError)
me@UKTH-NB306:~/git/ansible-dci-mgmt $ ansible-playbook -i /usr/local/etc/ansible/hosts bug.yaml -vvvv
ansible-playbook 2.4.0
config file = None
configured module search path = [u'/Users/me/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 2.7.13 (default, Apr  4 2017, 08:47:57) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]
No config file found; using defaults
setting up inventory plugins
Parsed /usr/local/etc/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/plugins/callback/__init__.pyc

PLAYBOOK: bug.yaml ***************************************************************************************************************************************************************************************************************************
1 plays in bug.yaml

PLAY [hgt_dci] *******************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/basic.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/collector.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/namespace.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/default_collectors.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/_text.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/pycompat24.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/six/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/six/_six.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/timeout.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/freebsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/openbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/base.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/dragonfly.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/dragonfly.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/aix.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/aix.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/linux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/platform.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/hpux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/user.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/hurd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/other/facter.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/sunos.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/hpux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/distribution.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/freebsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/openbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/darwin.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/linux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/sunos.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/sunos.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/apparmor.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/openbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/local.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/other/ohai.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/other/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/service_mgr.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/hurd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/hpux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/fips.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/selinux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/pkg_mgr.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/dns.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/base.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/darwin.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/dragonfly.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/ssh_pub_keys.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/lsb.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/date_time.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/netbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/base.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/cmdline.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/freebsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/netbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/hardware/netbsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/caps.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/env.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/linux.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/system/python.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/network/generic_bsd.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/virtual/sysctl.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/utils.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/facts/sysctl.py
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/system/setup.py
<1.1.1.157> ESTABLISH LOCAL CONNECTION FOR USER: me
<1.1.1.157> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/system/setup.py
<1.1.1.158> ESTABLISH LOCAL CONNECTION FOR USER: me
<1.1.1.158> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355 `" &amp;&amp; echo ansible-tmp-1499553151.25-263804456879355="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355 `" ) &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400 `" &amp;&amp; echo ansible-tmp-1499553151.25-98783112996400="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400 `" ) &amp;&amp; sleep 0'
<1.1.1.157> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmpwQ8UT1 TO /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355/setup.py
<1.1.1.158> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmpgwvJOf TO /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400/setup.py
<1.1.1.157> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355/ /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355/setup.py &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400/ /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400/setup.py &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355/setup.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553151.25-263804456879355/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400/setup.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553151.25-98783112996400/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
ok: [1.1.1.157]
ok: [1.1.1.158]
META: ran handlers

TASK [ENSURE PORT IS LAYER 2] ****************************************************************************************************************************************************************************************************************
task path: /Users/me/git/ansible-dci-mgmt/bug.yaml:17
<1.1.1.157> connection transport is nxapi
<1.1.1.158> connection transport is nxapi
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/basic.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/nxos.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/_text.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/pycompat24.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/six/__init__.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/six/_six.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/connection.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/network_common.py
Using module_utils file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/module_utils/urls.py
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/network/nxos/nxos_interface.py
<1.1.1.157> ESTABLISH LOCAL CONNECTION FOR USER: me
<1.1.1.157> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/network/nxos/nxos_interface.py
<1.1.1.158> ESTABLISH LOCAL CONNECTION FOR USER: me
<1.1.1.158> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904 `" &amp;&amp; echo ansible-tmp-1499553152.88-56984133901904="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904 `" ) &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096 `" &amp;&amp; echo ansible-tmp-1499553152.88-28761587341096="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096 `" ) &amp;&amp; sleep 0'
<1.1.1.158> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmpXYXrSD TO /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904/nxos_interface.py
<1.1.1.157> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmpt80d20 TO /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096/nxos_interface.py
<1.1.1.158> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904/ /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904/nxos_interface.py &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096/ /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096/nxos_interface.py &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904/nxos_interface.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553152.88-56984133901904/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096/nxos_interface.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553152.88-28761587341096/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py", line 712, in <module>
main()
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py", line 638, in main
existing, is_default = smart_existing(module, intf_type, normalized_interface)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py", line 535, in smart_existing
all_interfaces = get_interfaces_dict(module)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py", line 391, in get_interfaces_dict
interface_list = body.get('TABLE_interface')['ROW_interface']
AttributeError: 'unicode' object has no attribute 'get'

failed: [1.1.1.157] (item=Eth1/11) => {
"changed": false,
"failed": true,
"item": "Eth1/11",
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py\", line 712, in <module>\n    main()\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py\", line 638, in main\n    existing, is_default = smart_existing(module, intf_type, normalized_interface)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py\", line 535, in smart_existing\n    all_interfaces = get_interfaces_dict(module)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_8X3hEp/ansible_module_nxos_interface.py\", line 391, in get_interfaces_dict\n    interface_list = body.get('TABLE_interface')['ROW_interface']\nAttributeError: 'unicode' object has no attribute 'get'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
<1.1.1.157> connection transport is nxapi
The full traceback is:
Traceback (most recent call last):
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py", line 712, in <module>
main()
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py", line 638, in main
existing, is_default = smart_existing(module, intf_type, normalized_interface)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py", line 535, in smart_existing
all_interfaces = get_interfaces_dict(module)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py", line 391, in get_interfaces_dict
interface_list = body.get('TABLE_interface')['ROW_interface']
AttributeError: 'unicode' object has no attribute 'get'

failed: [1.1.1.158] (item=Eth1/11) => {
"changed": false,
"failed": true,
"item": "Eth1/11",
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py\", line 712, in <module>\n    main()\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py\", line 638, in main\n    existing, is_default = smart_existing(module, intf_type, normalized_interface)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py\", line 535, in smart_existing\n    all_interfaces = get_interfaces_dict(module)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_Pr3N93/ansible_module_nxos_interface.py\", line 391, in get_interfaces_dict\n    interface_list = body.get('TABLE_interface')['ROW_interface']\nAttributeError: 'unicode' object has no attribute 'get'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/network/nxos/nxos_interface.py
<1.1.1.158> connection transport is nxapi
<1.1.1.157> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
Using module file /usr/local/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible/modules/network/nxos/nxos_interface.py
<1.1.1.158> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829 `" &amp;&amp; echo ansible-tmp-1499553155.52-219207280744829="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829 `" ) &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123 `" &amp;&amp; echo ansible-tmp-1499553155.52-24952773001123="` echo /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123 `" ) &amp;&amp; sleep 0'
<1.1.1.157> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmpuJqAcm TO /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829/nxos_interface.py
<1.1.1.158> PUT /var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/tmptooEAE TO /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123/nxos_interface.py
<1.1.1.158> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123/ /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123/nxos_interface.py &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c 'chmod u+x /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829/ /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829/nxos_interface.py &amp;&amp; sleep 0'
<1.1.1.158> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123/nxos_interface.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553155.52-24952773001123/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
<1.1.1.157> EXEC /bin/sh -c '/usr/bin/python /Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829/nxos_interface.py; rm -rf "/Users/me/.ansible/tmp/ansible-tmp-1499553155.52-219207280744829/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py", line 712, in <module>
main()
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py", line 638, in main
existing, is_default = smart_existing(module, intf_type, normalized_interface)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py", line 535, in smart_existing
all_interfaces = get_interfaces_dict(module)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py", line 391, in get_interfaces_dict
interface_list = body.get('TABLE_interface')['ROW_interface']
AttributeError: 'unicode' object has no attribute 'get'

failed: [1.1.1.158] (item=Eth1/12) => {
"changed": false,
"failed": true,
"item": "Eth1/12",
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py\", line 712, in <module>\n    main()\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py\", line 638, in main\n    existing, is_default = smart_existing(module, intf_type, normalized_interface)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py\", line 535, in smart_existing\n    all_interfaces = get_interfaces_dict(module)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_yTkiS2/ansible_module_nxos_interface.py\", line 391, in get_interfaces_dict\n    interface_list = body.get('TABLE_interface')['ROW_interface']\nAttributeError: 'unicode' object has no attribute 'get'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
The full traceback is:
Traceback (most recent call last):
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py", line 712, in <module>
main()
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py", line 638, in main
existing, is_default = smart_existing(module, intf_type, normalized_interface)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py", line 535, in smart_existing
all_interfaces = get_interfaces_dict(module)
File "/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py", line 391, in get_interfaces_dict
interface_list = body.get('TABLE_interface')['ROW_interface']
AttributeError: 'unicode' object has no attribute 'get'

failed: [1.1.1.157] (item=Eth1/12) => {
"changed": false,
"failed": true,
"item": "Eth1/12",
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py\", line 712, in <module>\n    main()\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py\", line 638, in main\n    existing, is_default = smart_existing(module, intf_type, normalized_interface)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py\", line 535, in smart_existing\n    all_interfaces = get_interfaces_dict(module)\n  File \"/var/folders/cw/v5xqyw_57bg56tq3vgjnjgqjllcqpz/T/ansible_tmUHW6/ansible_module_nxos_interface.py\", line 391, in get_interfaces_dict\n    interface_list = body.get('TABLE_interface')['ROW_interface']\nAttributeError: 'unicode' object has no attribute 'get'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
to retry, use: --limit @/Users/me/git/ansible-dci-mgmt/bug.retry

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
1.1.1.157             : ok=1    changed=0    unreachable=0    failed=1
1.1.1.158             : ok=1    changed=0    unreachable=0    failed=1

# Fixed code
def execute_show_command(command, module):
    if "show run" not in command:
        output = "json"
    else:
        output = "text"
    cmds = [
        {
            "command": command,
            "output": output,
        }
    ]

    body = run_commands(module, cmds)
    return body