Repository: ansible/ansible

Issue:
eos_banner integration test failing
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
eos_banner
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
2.5
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->

##### SUMMARY
<!--- Explain the problem briefly -->

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
/var/lib/nodepool/dci-workspace/73b710ae-a9b9-4acd-b4c3-125d77ec8ecd/ansible/test/integration/targets/eos_banner/tests/cli/basic-login.yaml:8
eos: eos_banner : Create login banner authorize=True, text=Junk login banner over multiple lines , state=present, banner=login, provider={{ cli }}
{
"changed": false, 
"commands": [
"banner login", 
"Junk login banner", 
"over multiple lines", 
"EOF"
], 
"msg": "socket_path does not exist or cannot be found"
}
```



Discussion:
Files identified in the description:
* [lib/ansible/modules/network/eos/eos_banner.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/eos/eos_banner.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @privateip @trishnaguha
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py
--- a/lib/ansible/module_utils/eos.py
+++ b/lib/ansible/module_utils/eos.py
@@ -195,6 +195,7 @@ def configure(self, commands):
 
         rc, out, err = self.send_config(commands)
         if rc != 0:
+            self.exec_command('abort')
             self._module.fail_json(msg=to_text(err, errors='surrogate_then_replace'))
 
         self.exec_command('end')
diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py
--- a/lib/ansible/plugins/action/eos.py
+++ b/lib/ansible/plugins/action/eos.py
@@ -108,7 +108,7 @@ def run(self, tmp=None, task_vars=None):
             out = conn.get_prompt()
             while '(config' in to_text(out, errors='surrogate_then_replace').strip():
                 display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
-                conn.send_command('exit')
+                conn.send_command('abort')
                 out = conn.get_prompt()
 
         result = super(ActionModule, self).run(tmp, task_vars)
diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py
--- a/lib/ansible/plugins/connection/network_cli.py
+++ b/lib/ansible/plugins/connection/network_cli.py
@@ -114,7 +114,7 @@ def exec_command(self, cmd, in_data=None, sudoable=True):
             try:
                 cmd = json.loads(to_text(cmd, errors='surrogate_or_strict'))
                 kwargs = {'command': to_bytes(cmd['command'], errors='surrogate_or_strict')}
-                for key in ('prompt', 'answer', 'send_only'):
+                for key in ('prompt', 'answer', 'sendonly'):
                     if cmd.get(key) is not None:
                         kwargs[key] = to_bytes(cmd[key], errors='surrogate_or_strict')
                 return self.send(**kwargs)
@@ -270,7 +270,6 @@ def receive(self, command=None, prompts=None, answer=None):
             recv.seek(offset)
 
             window = self._strip(recv.read())
-
             if prompts and not handled:
                 handled = self._handle_prompt(window, prompts, answer)
 
@@ -279,14 +278,14 @@ def receive(self, command=None, prompts=None, answer=None):
                 resp = self._strip(self._last_response)
                 return self._sanitize(resp, command)
 
-    def send(self, command, prompt=None, answer=None, send_only=False):
+    def send(self, command, prompt=None, answer=None, sendonly=False):
         '''
         Sends the command to the device in the opened shell
         '''
         try:
             self._history.append(command)
             self._ssh_shell.sendall(b'%s\r' % command)
-            if send_only:
+            if sendonly:
                 return
             response = self.receive(command, prompt, answer)
             return to_text(response, errors='surrogate_or_strict')


Test patch:
diff --git a/test/integration/targets/eos_static_route/tests/cli/basic.yaml b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
--- a/test/integration/targets/eos_static_route/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
@@ -60,8 +60,8 @@
     aggregate:
       - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
       - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
-  authorize: yes
-  provider: "{{ cli }}"
+    authorize: yes
+    provider: "{{ cli }}"
   register: result
 
 - assert: