Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check ios cli context and exits config mode if there #21544

Merged
merged 1 commit into from
Feb 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/ansible/plugins/action/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@
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
)
Expand Down Expand Up @@ -70,9 +76,9 @@ def run(self, tmp=None, task_vars=None):
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

Expand Down