# Buggy code
def execute_show_command(command, module, command_type="cli_show"):
    transport = module.params["provider"]["transport"]
    if transport in ["cli", None]:
        if "show run" not in command:
            command += " | json"
        cmds = [command]
        body = run_commands(module, cmds)
    else:
        cmds = [command]
        body = run_commands(module, cmds)
    return body


# Traceback (TypeError)
ubuntu@ubuntu-xenial:/vagrant/ansible-nxos$ ansible-playbook -i hosts test1.yml -u cisco -k
SSH password:

PLAY [vlan testing] ************************************************************************************************************************************************************************************************************************************************


TASK [Create vrfs] *************************************************************************************************************************************************************************************************************************************************

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object has no attribute '__getitem__'
fatal: [sp2]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_BBb2AR/ansible_module_nxos_vrf.py\", line 326, in <module>\n    main()\n  File \"/tmp/ansible_BBb2AR/ansible_module_nxos_vrf
.py\", line 269, in main\n    existing = get_vrf(vrf, module)\n  File \"/tmp/ansible_BBb2AR/ansible_module_nxos_vrf.py\", line 215, in get_vrf\n    body = execute_show_command(command, module)\n  File \"/tmp/ansible_BBb2AR/ansible_module_nxos_vrf.py\", line 12
9, in execute_show_command\n    transport = module.params['provider']['transport']\nTypeError: 'NoneType' object has no attribute '__getitem__'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object has no attribute '__getitem__'
fatal: [sp1]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_4Mqx2r/ansible_module_nxos_vrf.py\", line 326, in <module>\n    main()\n  File \"/tmp/ansible_4Mqx2r/ansible_module_nxos_vrf
.py\", line 269, in main\n    existing = get_vrf(vrf, module)\n  File \"/tmp/ansible_4Mqx2r/ansible_module_nxos_vrf.py\", line 215, in get_vrf\n    body = execute_show_command(command, module)\n  File \"/tmp/ansible_4Mqx2r/ansible_module_nxos_vrf.py\", line 12
9, in execute_show_command\n    transport = module.params['provider']['transport']\nTypeError: 'NoneType' object has no attribute '__getitem__'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
to retry, use: --limit @/vagrant/ansible-nxos/test1.retry

PLAY RECAP *********************************************************************************************************************************************************************************************************************************************************

sp1                        : ok=0    changed=0    unreachable=0    failed=1
sp2                        : ok=0    changed=0    unreachable=0    failed=1

--------

It looks like although provider is an optional parameter, it is required in configuration because of line 129 in source code.

# Fixed code
def execute_show_command(command, module):
    transport = module.params["transport"]
    if transport == "cli":
        if "show run" not in command:
            command += " | json"

    cmds = [command]
    body = run_commands(module, cmds)
    return body