Repository: ansible/ansible

Issue:
eos_command: TypeError: 'ModuleStub' object has no attribute '__getitem__'
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
eos_command

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.2.0
  config file = /geiger/scripts/automate/ansible.cfg
  configured module search path = Default w/o overrides
```
Installed via: `pip install git+git://github.com/ansible/ansible.git@stable-2.2`

##### CONFIGURATION
```
provider:
  host: '{{ inventory_hostname }}'
  username: '{{ eapi_username }}'
  password: '{{ eapi_passwd }}'
  authorize: '{{ authorize }}'
  transport: eapi
  use_ssl: true
  validate_certs: false
```

##### OS / ENVIRONMENT
`Linux faee455d4c00 4.9.4-moby #1 SMP Wed Jan 18 17:04:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux`
```
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
```

##### SUMMARY
The eos_command module fails to run.  This same exact command working in Ansible 2.2.0.0.

##### 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.
-->

```yaml
---
- hosts: eos
  gather_facts: no
  connection: local

  tasks:
    - name: Show Version
      eos_command:
        commands:
          - command: 'show version'
            output: 'text'
        provider: '{{ provider }}'
```

##### EXPECTED RESULTS
It should return the contents of show version

##### ACTUAL RESULTS
```
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/network/eos/eos_command.py
<lf2> ESTABLISH LOCAL CONNECTION FOR USER: root
<lf2> EXEC /bin/sh -c 'echo ~ && sleep 0'
<lf2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732 `" && echo ansible-tmp-1487950019.58-19960267572732="` echo /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732 `" ) && sleep 0'
<lf2> PUT /tmp/tmpgEtOGi TO /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732/eos_command.py
<lf2> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732/ /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732/eos_command.py && sleep 0'
<lf2> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732/eos_command.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1487950019.58-19960267572732/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_TYO0ov/ansible_module_eos_command.py", line 255, in <module>
    main()
  File "/tmp/ansible_TYO0ov/ansible_module_eos_command.py", line 228, in main
    runner.run()
  File "/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/netcli.py", line 170, in run
  File "/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/netcli.py", line 98, in run_commands
  File "/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/eos.py", line 250, in run_commands
  File "/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/eos.py", line 209, in execute
TypeError: 'ModuleStub' object has no attribute '__getitem__'

fatal: [XXX]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "eos_command"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_TYO0ov/ansible_module_eos_command.py\", line 255, in <module>\n    main()\n  File \"/tmp/ansible_TYO0ov/ansible_module_eos_command.py\", line 228, in main\n    runner.run()\n  File \"/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/netcli.py\", line 170, in run\n  File \"/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/netcli.py\", line 98, in run_commands\n  File \"/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/eos.py\", line 250, in run_commands\n  File \"/tmp/ansible_TYO0ov/ansible_modlib.zip/ansible/module_utils/eos.py\", line 209, in execute\nTypeError: 'ModuleStub' object has no attribute '__getitem__'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE"
}
```



Discussion:
cc @privateip @gundalow @Qalthos
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Hi folks - I am also experiencing the same issue with `eos_config` and 2.2.2.0 (on OSX) - this seems to be fixed in 2.3.0 installed via `pip install git+git://github.com/ansible/ansible.git@devel`
+1
@CullyB Can you please clarify your `+1` please, e.g. do you see the error in 2.2.2.0, does it work for you in 2.3?
I can confirm that this issue occurs in 2.2, but not in 2.3
For what its worth we see this issue on almost any playbook run with eos_command or eos_config using 2.2.1.0 and 2.2.2.0 and using transport using eapi.  If you need more details from a recreate let me know I am happy to help.
This is fixed now for `2.3`/`devel`.

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
@@ -206,7 +206,7 @@ def execute(self, commands, output='json', **kwargs):
         data = json.dumps(body)
 
         headers = {'Content-Type': 'application/json-rpc'}
-        timeout = self.url_args['timeout']
+        timeout = self.url_args.params['timeout']
 
         response, headers = fetch_url(
             self.url_args, self.url, data=data, headers=headers,


Test patch: