From a01288859da1014d622979b270db98c3ab8249cd Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 16 Feb 2017 20:26:29 -0500 Subject: [PATCH] check ios cli context and exits config mode if there (#21544) --- lib/ansible/plugins/action/ios.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 13daf0fada..d1257c35ef 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -31,13 +31,19 @@ from ansible.module_utils.ios import ios_argument_spec from ansible.module_utils.basic import AnsibleFallbackNotFound from ansible.module_utils._text import to_bytes +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() + class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): if self._play_context.connection != 'local': return dict( - fail=True, + failed=True, msg='invalid connection specified, expected connection=local, ' 'got %s' % self._play_context.connection ) @@ -70,9 +76,9 @@ class ActionModule(_ActionModule): results = super(ActionModule, self).run(tmp, task_vars) # need to make sure to leave config mode if the module didn't clean up - rc, out, err = connection.exec_command('EXEC: prompt()') + rc, out, err = connection.exec_command('prompt()') if str(out).strip().endswith(')#'): - connection.exec_command('EXEC: exit') + connection.exec_command('exit') return results