Repository: ansible/ansible

Issue:
eos_config - TypeError: configure() takes exactly 2 arguments (3 given)
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
eos_config

##### ANSIBLE VERSION
```
ansible-playbook 2.4.0 (devel 94748e1728) last updated 2017/08/02 10:19:20 (GMT +000)
  config file = /home/lynchg/git/ansible_arista/ansible.cfg
  configured module search path = [u'/home/lynchg/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lynchg/git/ansible/lib/ansible
  executable location = /home/lynchg/git/ansible/bin/ansible-playbook
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
```

##### CONFIGURATION

```
defaults]
inventory           = inventory
roles_path          = roles
filter_plugins      = plugins/filter
host_key_checking   = False
retry_files_enabled = False
```

```
ansible_arista]$ env | grep ^ANSIBLE
ANSIBLE_HOME=/home/lynchg/git/ansible
```

##### OS / ENVIRONMENT
`CentOS Linux release 7.3.1611 (Core)`

##### SUMMARY
Running eos_config with `replace: config` results in a python TypeError.

##### STEPS TO REPRODUCE

I've hit this on a rather large project, so will put together a smaller test case.

```yaml
# build a startup-config using templates and assemble

- name: replace configuration from file
  eos_config:
    src: "{{ eos_dest_dir }}/startup-config"
    replace: config
    save: yes
    provider: "{{ eos_connection }}"
```

##### EXPECTED RESULTS
No error, config to be replaced on the switch

##### ACTUAL RESULTS
```
TASK [eos : replace configuration from file] ***********************************************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: configure() takes exactly 2 arguments (3 given)
fatal: [TL1MCSW01]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_S_CQ4R/ansible_module_eos_config.py\", line 467, in <module>\n    main()\n  File \"/tmp/ansible_S_CQ4R/ansible_module_eos_config.py\", line 394, in main\n    response = load_config(module, commands, replace=replace, commit=commit)\n  File \"/tmp/ansible_S_CQ4R/ansible_modlib.zip/ansible/module_utils/eos.py\", line 476, in load_config\n  File \"/tmp/ansible_S_CQ4R/ansible_modlib.zip/ansible/module_utils/eos.py\", line 406, in load_config\nTypeError: configure() takes exactly 2 arguments (3 given)\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
```

Running the file directly after using `ANSIBLE_KEEP_REMOTE_FILES=1`
```
python ~/.ansible/tmp/ansible-tmp-1501669213.05-9674598647122/eos_config.py
Traceback (most recent call last):
  File "/tmp/ansible_fJ2U45/ansible_module_eos_config.py", line 467, in <module>
    main()
  File "/tmp/ansible_fJ2U45/ansible_module_eos_config.py", line 394, in main
    response = load_config(module, commands, replace=replace, commit=commit)
  File "/tmp/ansible_fJ2U45/ansible_modlib.zip/ansible/module_utils/eos.py", line 476, in load_config
  File "/tmp/ansible_fJ2U45/ansible_modlib.zip/ansible/module_utils/eos.py", line 406, in load_config
TypeError: configure() takes exactly 2 arguments (3 given)
```



Discussion:
I have zero idea why this might be happening, because when I look at the code https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/eos.py#L406 there appear to be only 2 arguments passed.

Note that I'm using devel because I got a different bug in 2.3.1, so I assume _something_ has changed since then.

```
# with ansible 2.3.1
python ~/.ansible/tmp/ansible-tmp-1501668349.54-152206403236310/eos_config.py
Traceback (most recent call last):
  File "/tmp/ansible_Pkq9_e/ansible_module_eos_config.py", line 341, in <module>
    main()
  File "/tmp/ansible_Pkq9_e/ansible_module_eos_config.py", line 330, in main
    run(module, result)
  File "/tmp/ansible_Pkq9_e/ansible_module_eos_config.py", line 265, in run
    response = load_config(module, commands, replace=replace, commit=commit)
  File "/tmp/ansible_Pkq9_e/ansible_modlib.zip/ansible/module_utils/eos.py", line 463, in load_config
  File "/tmp/ansible_Pkq9_e/ansible_modlib.zip/ansible/module_utils/eos.py", line 397, in load_config
NameError: global name 'configure' is not defined
```
cc @privateip
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
@halberom I am unable to get this issue reproduced. 
But different failure here:
```
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_GBuSRL/ansible_module_eos_config.py", line 467, in <module>
    main()
  File "/tmp/ansible_GBuSRL/ansible_module_eos_config.py", line 394, in main
    response = load_config(module, commands, replace=replace, commit=commit)
  File "/tmp/ansible_GBuSRL/ansible_modlib.zip/ansible/module_utils/eos.py", line 476, in load_config
  File "/tmp/ansible_GBuSRL/ansible_modlib.zip/ansible/module_utils/eos.py", line 243, in load_config
TypeError: exec_command() got an unexpected keyword argument 'check_rc'

fatal: [veos01]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_GBuSRL/ansible_module_eos_config.py\", line 467, in <module>\n    main()\n  File \"/tmp/ansible_GBuSRL/ansible_module_eos_config.py\", line 394, in main\n    response = load_config(module, commands, replace=replace, commit=commit)\n  File \"/tmp/ansible_GBuSRL/ansible_modlib.zip/ansible/module_utils/eos.py\", line 476, in load_config\n  File \"/tmp/ansible_GBuSRL/ansible_modlib.zip/ansible/module_utils/eos.py\", line 243, in load_config\nTypeError: exec_command() got an unexpected keyword argument 'check_rc'\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}
	to retry, use: --limit @/home/tguha/RHWork/ansible/hacking/example/eosconfig.retry

PLAY RECAP ********************************************************************************************************************************************************************************************************
veos01                     : ok=1    changed=0    unreachable=0    failed=1   
```
@halberom with this PR https://github.com/ansible/ansible/pull/27683 applied I am able to run the same playbook on devel 2.4.
For 2.3, please apply the patch https://github.com/ansible/ansible/pull/27684.
resolved_by_pr https://github.com/ansible/ansible/pull/27683

Resolving patch:
diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py
--- a/lib/ansible/module_utils/network/eos/eos.py
+++ b/lib/ansible/module_utils/network/eos/eos.py
@@ -232,7 +232,7 @@ def load_config(self, commands, commit=False, replace=False):
 
         if not all((bool(use_session), self.supports_sessions)):
             if commit:
-                return self.configure(self, commands)
+                return self.configure(commands)
             else:
                 self._module.warn("EOS can not check config without config session")
                 result = {'changed': True}
@@ -420,7 +420,7 @@ def load_config(self, config, commit=False, replace=False):
 
         if not all((bool(use_session), self.supports_sessions)):
             if commit:
-                return self.configure(self, config)
+                return self.configure(config)
             else:
                 self._module.warn("EOS can not check config without config session")
                 result = {'changed': True}


Test patch: