Repository: ansible/ansible-modules-core

Issue:
Document EOS Min Version
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

eos_template, eos_config
##### ANSIBLE VERSION

2.2
##### SUMMARY

The latest implementation in devel for 2.2 uses a feature in EOS, session-config.  This feature was introduced in EOS 4.15.0F.  Therefore, the module documentation should clearly indicate this, otherwise you end up with:

```
TASK [Arista EOS Base Configuration] *******************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: localhost(config-s-ansibl)#
fatal: [172.16.130.201]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_5GSPsQ/ansible_module_eos_template.py\", line 213, in <module>\n    main()\n  File \"/tmp/ansible_5GSPsQ/ansible_module_eos_template.py\", line 205, in main\n    commit=True)\n  File \"/tmp/ansible_5GSPsQ/ansible_modlib.zip/ansible/module_utils/netcfg.py\", line 58, in load_config\n  File \"/tmp/ansible_5GSPsQ/ansible_modlib.zip/ansible/module_utils/eos.py\", line 78, in load_config\n  File \"/tmp/ansible_5GSPsQ/ansible_modlib.zip/ansible/module_utils/eos.py\", line 102, in diff_config\n  File \"/tmp/ansible_5GSPsQ/ansible_modlib.zip/ansible/module_utils/shell.py\", line 252, in execute\nansible.module_utils.network.NetworkError: matched error in response: show session-config diffs\r\n% Invalid input\r\nlocalhost(config-s-ansibl)#\n", "module_stdout": "", "msg": "MODULE FAILURE"}
    to retry, use: --limit @/ansi/base_configuration.retry

PLAY RECAP *********************************************************************
172.16.130.201             : ok=0    changed=0    unreachable=0    failed=1
```

I'd also like to recommend looking for `invalid input` and maybe offering a better message which hints to the user that their version of EOS is too old.



Discussion:
@gundalow @privateip 

changed this to a `bug_report` and I think the right way to handle this is to revert to not using config sessions if the device version < 4.15.0F

@privateip, @gundalow, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->


Resolving patch:
diff --git a/network/eos/eos_config.py b/network/eos/eos_config.py
--- a/network/eos/eos_config.py
+++ b/network/eos/eos_config.py
@@ -223,6 +223,11 @@ def check_args(module, warnings):
                         'match=none instead.  This argument will be '
                         'removed in the future')
 
+    if not module.connection.supports_sessions():
+        warnings.append('The current version of EOS on the remote device does '
+                        'not support configuration sessions.  The commit '
+                        'argument will be ignored')
+
 def get_candidate(module):
     candidate = NetworkConfig(indent=3)
     if module.params['src']:
@@ -245,9 +250,11 @@ def load_config(module, commands, result):
 
     diff = module.config.load_config(commands, replace=replace, commit=commit)
 
-    if diff:
+    if diff and module.connection.supports_sessions():
         result['diff'] = dict(prepared=diff)
         result['changed'] = True
+    elif diff:
+        result['changed'] = True
 
 def run(module, result):
     match = module.params['match']
@@ -273,6 +280,7 @@ def run(module, result):
 
             result['updates'] = commands
 
+        module.log('commands: %s' % commands)
         load_config(module, commands, result)
 
     if module.params['save']:
@@ -314,7 +322,6 @@ def main():
                    ('replace', 'config', ['src'])]
 
     module = NetworkModule(argument_spec=argument_spec,
-                           connect_on_load=False,
                            mutually_exclusive=mutually_exclusive,
                            required_if=required_if,
                            supports_check_mode=True)


Test patch: