1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Match config prompts that aren't maint-mode (#47678)

This commit is contained in:
Nathaniel Case 2018-11-12 11:18:06 -05:00 committed by GitHub
parent 320d72f08f
commit 1fff542623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,8 +19,9 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import sys
import copy import copy
import re
import sys
from ansible import constants as C from ansible import constants as C
from ansible.module_utils._text import to_text from ansible.module_utils._text import to_text
@ -117,8 +118,10 @@ class ActionModule(_ActionModule):
socket_path = self._connection.socket_path socket_path = self._connection.socket_path
conn = Connection(socket_path) conn = Connection(socket_path)
# Match prompts ending in )# except those with (maint-mode)#
config_prompt = re.compile(r'^.*\((?!maint-mode).*\)#$')
out = conn.get_prompt() out = conn.get_prompt()
while to_text(out, errors='surrogate_then_replace').strip().endswith(')#'): while config_prompt.match(to_text(out, errors='surrogate_then_replace').strip()):
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr) display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()