# Buggy code
def discard_changes(module, exit=False):
    conn = get_connection(module)
    return conn.discard_changes(exit=exit)


# Traceback (ansible.module_utils.connection.ConnectionError)
TASK [junos_smoke : check mode] *******************************************************************************************
task path: /Users/david/code/ansible/test/integration/targets/junos_smoke/tests/netconf/module_utils_junos.yaml:46
<junos01> attempting to start connection
<junos01> using connection plugin netconf
<junos01> found existing local domain socket, using it!
<junos01>
<junos01> local domain socket path is /Users/david/.ansible/pc/0319a6a111
[WARNING]: provider is unnecessary when using connection=netconf and will be ignored

Using module file /Users/david/code/ansible/lib/ansible/modules/network/junos/junos_banner.py
<junos01> ESTABLISH LOCAL CONNECTION FOR USER: david
<junos01> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<junos01> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716 `" &amp;&amp; echo ansible-tmp-1520531921.38-75952063324716="` echo /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716 `" ) &amp;&amp; sleep 0'
<junos01> PUT /Users/david/.ansible/tmp/ansible-local-65800g9taGD/tmpXZT5uE TO /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716/junos_banner.py
<junos01> EXEC /bin/sh -c 'chmod u+x /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716/ /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716/junos_banner.py &amp;&amp; sleep 0'
<junos01> EXEC /bin/sh -c '/tmp/ansible-test-coverage-V8NjOc/coverage/injector.py /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716/junos_banner.py &amp;&amp; sleep 0'
<junos01> EXEC /bin/sh -c 'rm -f -r /Users/david/.ansible/tmp/ansible-tmp-1520531921.38-75952063324716/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_TzxF82/ansible_module_junos_banner.py", line 180, in <module>
main()
File "/tmp/ansible_TzxF82/ansible_module_junos_banner.py", line 171, in main
discard_changes(module)
File "/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/junos/junos.py", line 185, in discard_changes
File "/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/common/netconf.py", line 70, in __rpc__
File "/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/common/netconf.py", line 102, in parse_rpc_error
ansible.module_utils.connection.ConnectionError: request() got an unexpected keyword argument 'exit'

fatal: [junos01]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_TzxF82/ansible_module_junos_banner.py\", line 180, in <module>\n    main()\n  File \"/tmp/ansible_TzxF82/ansible_module_junos_banner.py\", line 171, in main\n    discard_changes(module)\n  File \"/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/junos/junos.py\", line 185, in discard_changes\n  File \"/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/common/netconf.py\", line 70, in __rpc__\n  File \"/tmp/ansible_TzxF82/ansible_modlib.zip/ansible/module_utils/network/common/netconf.py\", line 102, in parse_rpc_error\nansible.module_utils.connection.ConnectionError: request() got an unexpected keyword argument 'exit'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def discard_changes(module):
    conn = get_connection(module)
    return conn.discard_changes()