# Buggy code
def edit_config(self, command):
    responses = []
    for cmd in chain(["configure"], to_list(command), ["end"]):
        responses.append(self.send_command(cmd))

    return json.dumps(responses)


# Traceback (AttributeError)
TASK [nxos_install_os : Install OS image nxos.7.0.3.I7.3.bin] ******************************************************************************************************************************************************
task path: /root/agents-ci/ansible/test/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml:2
<n9k.example.com> loaded API plugin for network_os nxos
<n9k.example.com> attempting to start connection
<n9k.example.com> using connection plugin httpapi
<n9k.example.com> found existing local domain socket, using it!
<n9k.example.com> updating play_context for connection
<n9k.example.com>
<n9k.example.com> local domain socket path is /root/.ansible/pc/5622680378
<n9k.example.com> ESTABLISH LOCAL CONNECTION FOR USER: root
<n9k.example.com> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849 `" &amp;&amp; echo ansible-tmp-1528389129.96-5020047695849="` echo /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849 `" ) &amp;&amp; sleep 0'
Using module file /root/agents-ci/ansible/lib/ansible/modules/network/nxos/nxos_install_os.py
<n9k.example.com> PUT /root/.ansible/tmp/ansible-local-5469oaIAz6/tmpbsze4G TO /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849/nxos_install_os.py
<n9k.example.com> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849/ /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849/nxos_install_os.py &amp;&amp; sleep 0'
<n9k.example.com> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849/nxos_install_os.py &amp;&amp; sleep 0'
<n9k.example.com> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-5469oaIAz6/ansible-tmp-1528389129.96-5020047695849/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 545, in <module>
main()
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 530, in main
install_result = do_install_all(module, issu, sif, kick=kif)
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 460, in do_install_all
impact_data = check_mode(module, issu, image, kick)
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 449, in check_mode
data = check_mode_nextgen(module, issu, image, kick)
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 423, in check_mode_nextgen
data = parse_show_install(load_config(module, commands, True, opts))
File "/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py", line 223, in parse_show_install
ud['list_data'] = data.split('\n')
AttributeError: 'list' object has no attribute 'split'

fatal: [n9k.example.com]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 545, in <module>\n    main()\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 530, in main\n    install_result = do_install_all(module, issu, sif, kick=kif)\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 460, in do_install_all\n    impact_data = check_mode(module, issu, image, kick)\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 449, in check_mode\n    data = check_mode_nextgen(module, issu, image, kick)\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 423, in check_mode_nextgen\n    data = parse_show_install(load_config(module, commands, True, opts))\n  File \"/tmp/ansible__d5Rmh/ansible_module_nxos_install_os.py\", line 223, in parse_show_install\n    ud['list_data'] = data.split('\\n')\nAttributeError: 'list' object has no attribute 'split'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}
to retry, use: --limit @/root/agents-ci/ansible/test/integration/nxos.retry

PLAY RECAP *********************************************************************************************************************************************************************************************************
n9k.example.com          : ok=67   changed=5    unreachable=0    failed=1

# Fixed code
def edit_config(self, command):
    responses = []
    for cmd in chain(["configure"], to_list(command), ["end"]):
        responses.append(self.send_command(cmd))
    resp = responses[1:-1]
    return json.dumps(resp)