From 25d00838a949b8f0bdb7e780537237255b61d7b7 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Wed, 12 Oct 2016 20:16:34 -0400 Subject: [PATCH] fixes issue with pushing config to versions that do not support sessions (#5236) earlier versions of eos do not support configuration sessions. this change will now check if sessions are supported and if not will fallback to not using config sessions fixes #4909 --- lib/ansible/modules/network/eos/eos_config.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/eos/eos_config.py b/lib/ansible/modules/network/eos/eos_config.py index 6531a602d90..04d0c9f0fba 100644 --- a/lib/ansible/modules/network/eos/eos_config.py +++ b/lib/ansible/modules/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)