# Buggy code
def discard_changes(self, *args, **kwargs):
    self.send_command(b"discard")


# Traceback (ansible.module_utils.connection.ConnectionError)
TASK [Check intent arguments] ************************************************************************************************************************
task path: /Users/david/code/ansible/#david_stuff/vyos.yaml:20
<vyos02.example.net> attempting to start connection
<vyos02.example.net> using connection plugin network_cli
<vyos02.example.net> found existing local domain socket, using it!
<vyos02.example.net> updating play_context for connection
<vyos02.example.net>
<vyos02.example.net> local domain socket path is /Users/david/.ansible/pc/af7ff55793
Using module file /Users/david/code/ansible/lib/ansible/modules/network/vyos/vyos_interface.py
<vyos02.example.net> ESTABLISH LOCAL CONNECTION FOR USER: david
<vyos02.example.net> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<vyos02.example.net> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046 `" &amp;&amp; echo ansible-tmp-1517516417.19518-22304825954046="` echo /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046 `" ) &amp;&amp; sleep 0'
<vyos02.example.net> PUT /Users/david/.ansible/tmp/ansible-local-210906dn2dlh1/tmpu8uvlnd0 TO /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046/vyos_interface.py
<vyos02.example.net> EXEC /bin/sh -c 'chmod u+x /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046/ /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046/vyos_interface.py &amp;&amp; sleep 0'
<vyos02.example.net> EXEC /bin/sh -c '/usr/bin/python /Users/david/.ansible/tmp/ansible-tmp-1517516417.19518-22304825954046/vyos_interface.py &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_module_vyos_interface.py", line 434, in <module>
main()
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_module_vyos_interface.py", line 420, in main
diff = load_config(module, commands, commit=commit)
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_modlib.zip/ansible/module_utils/network/vyos/vyos.py", line 132, in load_config
File "/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_modlib.zip/ansible/module_utils/connection.py", line 146, in __rpc__
ansible.module_utils.connection.ConnectionError: configure

Invalid command: [configure]

[edit]
ansible@vyos02#

fatal: [vyos02.example.net]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_module_vyos_interface.py\", line 434, in <module>\n    main()\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_module_vyos_interface.py\", line 420, in main\n    diff = load_config(module, commands, commit=commit)\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_modlib.zip/ansible/module_utils/network/vyos/vyos.py\", line 132, in load_config\n  File \"/var/folders/x6/l9cfl1bs7x9_h9_v5sn94z640000gn/T/ansible_Mxw7Xt/ansible_modlib.zip/ansible/module_utils/connection.py\", line 146, in __rpc__\nansible.module_utils.connection.ConnectionError: configure\r\n\r\n  Invalid command: [configure]\r\n\r\n[edit]\r\r\nansible@vyos02# \n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def discard_changes(self, *args, **kwargs):
    self.send_command(b"exit discard")