mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
starts cli if root user login is used for junos terminal (#20761)
fixes #20131
This commit is contained in:
parent
c86a17b7a0
commit
d8e57cc60a
1 changed files with 11 additions and 1 deletions
|
@ -26,11 +26,17 @@ from ansible.plugins.terminal import TerminalBase
|
||||||
from ansible.errors import AnsibleConnectionFailure
|
from ansible.errors import AnsibleConnectionFailure
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from __main__ import display
|
||||||
|
except ImportError:
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
display = Display()
|
||||||
|
|
||||||
class TerminalModule(TerminalBase):
|
class TerminalModule(TerminalBase):
|
||||||
|
|
||||||
terminal_prompts_re = [
|
terminal_prompts_re = [
|
||||||
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
||||||
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|%) ?$"),
|
||||||
]
|
]
|
||||||
|
|
||||||
terminal_errors_re = [
|
terminal_errors_re = [
|
||||||
|
@ -40,6 +46,10 @@ class TerminalModule(TerminalBase):
|
||||||
|
|
||||||
def on_open_shell(self):
|
def on_open_shell(self):
|
||||||
try:
|
try:
|
||||||
|
prompt = self._get_prompt()
|
||||||
|
if prompt.strip().endswith('%'):
|
||||||
|
display.vvv('starting cli', self._connection._play_context.remote_addr)
|
||||||
|
self._exec_cli_command('cli')
|
||||||
for c in ['set cli timestamp disable', 'set cli screen-length 0']:
|
for c in ['set cli timestamp disable', 'set cli screen-length 0']:
|
||||||
self._exec_cli_command(c)
|
self._exec_cli_command(c)
|
||||||
except AnsibleConnectionFailure:
|
except AnsibleConnectionFailure:
|
||||||
|
|
Loading…
Reference in a new issue