fix: Fix pattern to handle long system identity (#386)
Some checks failed
nox / Run extra sanity tests (push) Has been cancelled
nox / ansible-test (push) Has been cancelled
Collection Docs / Build Ansible Docs (push) Has been cancelled
Collection Docs / Publish Ansible Docs (push) Has been cancelled

* fix: Fix pattern to handle long system identity names

When the system identity string is too long, the terminal output may be
truncated. The truncated output is marked by multiple carriage returns
(`\r`) and a `<` symbol.

This is a example of a truncated output:
`\r\n\r\r\r\r<MY_VERYVERY-LONG-SYSTEM-IDENTIY-NAME] > `

The existing regex failed to match these truncated prompts.
This update introduces a more flexible regex that matches both, the truncated and the preserved output.

* add change-log fragment for pr 386

* refactoring change-log fragment for pr 386

* Update changelogs/fragments/386-fix-pattern-to-handle-long-identity.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Jefferson Raylan 2025-07-31 17:02:47 -03:00 committed by GitHub
parent 8edc8018a7
commit 7395011b0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- routeros terminal plugin - fix ``terminal_stdout_re`` pattern to handle long system identities when connecting to RouterOS through SSH (https://github.com/ansible-collections/community.routeros/pull/386).

View file

@ -31,7 +31,9 @@ class TerminalModule(TerminalBase):
terminal_stdout_re = [ terminal_stdout_re = [
re.compile(br"\x1b<"), re.compile(br"\x1b<"),
re.compile(br"\[[\w\-\.]+\@[\w\s\-\.\/]+\] ?(<SAFE)?> ?$"), re.compile(
br"((\[[\w\-\.]+\@)|(\r\<(([\w\-\.]*\@)|)))"
br"[\w\s\-\.\/]+\] ?(<SAFE)?> ?$"),
re.compile(br"Please press \"Enter\" to continue!"), re.compile(br"Please press \"Enter\" to continue!"),
re.compile(br"Do you want to see the software license\? \[Y\/n\]: ?"), re.compile(br"Do you want to see the software license\? \[Y\/n\]: ?"),
] ]