# Buggy code
def has_lldp(module):
    output = run_commands(module, ["show lldp"])

    is_lldp_enable = False
    if len(output) > 0 and "LLDP is not enabled" not in output[0]:
        is_lldp_enable = True

    return is_lldp_enable


# Traceback (TypeError)
TASK [Check intent arguments] **********************************************************************************
task path: /Users/david/code/test/eos.yaml:8
<eos02> connection transport is eapi
Using module file /Users/david/code/ansible/lib/ansible/modules/network/eos/eos_interface.py
<eos02> ESTABLISH LOCAL CONNECTION FOR USER: david
<eos02> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<eos02> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350 `" &amp;&amp; echo ansible-tmp-1519930473.54-89724812253350="` echo /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350 `" ) &amp;&amp; sleep 0'
<eos02> PUT /Users/david/.ansible/tmp/ansible-local-199917TML_E/tmpgccdUR TO /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350/eos_interface.py
<eos02> EXEC /bin/sh -c 'chmod u+x /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350/ /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350/eos_interface.py &amp;&amp; sleep 0'
<eos02> EXEC /bin/sh -c '/usr/bin/python /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350/eos_interface.py &amp;&amp; sleep 0'
<eos02> EXEC /bin/sh -c 'rm -f -r /Users/david/.ansible/tmp/ansible-tmp-1519930473.54-89724812253350/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py", line 466, in <module>
main()
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py", line 456, in main
failed_conditions = check_declarative_intent_params(module, want, result)
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py", line 337, in check_declarative_intent_params
match = re.search(r'%s (\w+)' % 'line protocol is', output[0], re.M)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 146, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or buffer

fatal: [eos02]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py\", line 466, in <module>\n    main()\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py\", line 456, in main\n    failed_conditions = check_declarative_intent_params(module, want, result)\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Glr2s3/ansible_module_eos_interface.py\", line 337, in check_declarative_intent_params\n    match = re.search(r'%s (\\w+)' % 'line protocol is', output[0], re.M)\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py\", line 146, in search\n    return _compile(pattern, flags).search(string)\nTypeError: expected string or buffer\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def has_lldp(module):
    config = get_config(module, flags=["| section lldp"])

    is_lldp_enable = False
    if "no lldp run" not in config:
        is_lldp_enable = True

    return is_lldp_enable