Repository: ansible/ansible

Issue:
test_eos_command: "unable to load response from device"
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

module_utils/eos.py/m
##### ANSIBLE VERSION

```
ansible-playbook --version
ansible-playbook 2.2.0 (devel d67af04c45) last updated 2016/09/07 14:24:26 (GMT +100)
  lib/ansible/modules/core: (devel db38f0c876) last updated 2016/09/07 14:49:01 (GMT +100)
  lib/ansible/modules/extras: (devel 8bfdcfcab2) last updated 2016/09/07 14:49:33 (GMT +100)
  config file = /home/johnb/.ansible.cfg
  configured module search path = Default w/o overrides

```
##### CONFIGURATION
##### OS / ENVIRONMENT
##### SUMMARY

I'm unsure if the error is in `eos_command` or `lib/ansible/module_utils/eos.py`. I'm assuming in `module_utils` so raising in this repo.
##### STEPS TO REPRODUCE

```
ansible-playbook -vvv eos.yaml -i inventory
```
##### EXPECTED RESULTS

Clean run
##### ACTUAL RESULTS

```
TASK [test_eos_command : test contains operator] *******************************
task path: /home/johnb/git/ansible-inc/test-network-modules/roles/test_eos_command/tests/cli/contains.yaml:4
Using module file /home/johnb/git/ansible-inc/ansible/lib/ansible/modules/core/network/eos/eos_command.py
<veos01> ESTABLISH LOCAL CONNECTION FOR USER: johnb
<veos01> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1473256799.51-521237603843 `" && echo ansible-tmp-1473256799.51-521237603843="` echo $HOME/.ansible/tmp/ansible-tmp-1473256799.51-521237603843 `" ) && sleep 0'
<veos01> PUT /tmp/tmpvwxxeM TO /home/johnb/.ansible/tmp/ansible-tmp-1473256799.51-521237603843/eos_command.py
<veos01> EXEC /bin/sh -c 'chmod u+x /home/johnb/.ansible/tmp/ansible-tmp-1473256799.51-521237603843/ /home/johnb/.ansible/tmp/ansible-tmp-1473256799.51-521237603843/eos_command.py && sleep 0'
<veos01> EXEC /bin/sh -c 'python /home/johnb/.ansible/tmp/ansible-tmp-1473256799.51-521237603843/eos_command.py; rm -rf "/home/johnb/.ansible/tmp/ansible-tmp-1473256799.51-521237603843/" > /dev/null 2>&1 && sleep 0'
fatal: [veos01]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": null, 
            "authorize": true, 
            "commands": [
                "show version", 
                "show interface Management1 | json"
            ], 
            "host": "veos01", 
            "interval": 1, 
            "match": "all", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": null, 
            "provider": {
                "authorize": true, 
                "host": "veos01", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "cli", 
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            }, 
            "retries": 10, 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "cli", 
            "use_ssl": true, 
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "validate_certs": true, 
            "wait_for": [
                "result[0] contains EOS", 
                "result[1].interfaces.Management1.name contains Manage"
            ], 
            "waitfor": [
                "result[0] contains EOS", 
                "result[1].interfaces.Management1.name contains Manage"
            ]
        }, 
        "module_name": "eos_command"
    }, 
    "msg": "unable to load response from device"
}

```



Discussion:
Still occurring in 

```
ansible 2.2.0 (devel 697888965e) last updated 2016/09/16 13:36:43 (GMT +100)
  lib/ansible/modules/core: (devel 1df235f8ca) last updated 2016/09/19 09:15:02 (GMT +100)
  lib/ansible/modules/extras: (devel 88464efdc4) last updated 2016/09/19 09:15:26 (GMT +100)
```


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
@@ -268,26 +268,19 @@ class Cli(EosConfigMixin, CliBase):
     NET_PASSWD_RE = re.compile(r"[\r\n]?password: $", re.I)
 
     def connect(self, params, **kwargs):
-        super(Cli, self).connect(params, kickstart=True, **kwargs)
+        super(Cli, self).connect(params, kickstart=False, **kwargs)
         self.shell.send('terminal length 0')
 
     def authorize(self, params, **kwargs):
         passwd = params['auth_pass']
-        self.execute(Command('enable', prompt=self.NET_PASSWD_RE, response=passwd))
+        if passwd:
+            self.execute(Command('enable', prompt=self.NET_PASSWD_RE, response=passwd))
+        else:
+            self.execute('enable')
 
     ### Command methods ###
 
     def run_commands(self, commands):
-        """execute the ordered set of commands on the remote host
-
-        This method will take a list of Command objects, convert them
-        to a list of dict objects and execute them on the shell
-        connection.
-
-        :param commands: list of Command objects
-
-        :returns: set of ordered responses
-        """
         cmds = list(prepare_commands(commands))
         responses = self.execute(cmds)
         for index, cmd in enumerate(commands):
@@ -297,7 +290,8 @@ def run_commands(self, commands):
                 except ValueError:
                     raise NetworkError(
                         msg='unable to load response from device',
-                        response=responses[index]
+                        response=responses[index],
+                        responses=responses
                     )
         return responses
 
@@ -312,12 +306,6 @@ def prepare_config(commands):
 
 
 def prepare_commands(commands):
-    """ transforms a list of Command objects to dict
-
-    :param commands: list of Command objects
-
-    :returns: list of dict objects
-    """
     jsonify = lambda x: '%s | json' % x
     for item in to_list(commands):
         if item.output == 'json':


Test patch: