diff --git a/changelogs/fragments/terminal_initial_newline.yaml b/changelogs/fragments/terminal_initial_newline.yaml index 2cc78bdad..de6e94017 100644 --- a/changelogs/fragments/terminal_initial_newline.yaml +++ b/changelogs/fragments/terminal_initial_newline.yaml @@ -1,2 +1,2 @@ minor_changes: - - network_cli - add `terminal_initial_newline` parameter as an option for terminal plugins. \ No newline at end of file + - network_cli - add `terminal_initial_newline` parameter as an option for terminal plugins. diff --git a/docs/ansible.netcommon.network_cli_connection.rst b/docs/ansible.netcommon.network_cli_connection.rst index 35250272d..5590c8e21 100644 --- a/docs/ansible.netcommon.network_cli_connection.rst +++ b/docs/ansible.netcommon.network_cli_connection.rst @@ -540,6 +540,26 @@ Parameters
The answer to reply with if the terminal_initial_prompt is matched. The value can be a single answer or a list of answers for multiple terminal_initial_prompt. In case the login menu has multiple prompts the sequence of the prompt and excepted answer should be in same order and the value of terminal_prompt_checkall should be set to True if all the values in terminal_initial_prompt are expected to be matched and set to False if any one login prompt is to be matched.
+ + +
+ terminal_initial_newline + +
+ boolean +
+ + + Default:
"no"
+ + +
var: ansible_terminal_inital_newline
+ + +
This boolean flag, that when set to True will send newline on initial connection establishment to the remote device.
+
This can be useful for equipment which does not send an initial header until it receives some input, like Serial-to-SSH multiplexer hardware.
+ +
diff --git a/plugins/connection/network_cli.py b/plugins/connection/network_cli.py index 6da0485e9..3984784ca 100644 --- a/plugins/connection/network_cli.py +++ b/plugins/connection/network_cli.py @@ -667,7 +667,8 @@ def _connect(self): ) terminal_initial_newline = ( - self.get_option("terminal_initial_newline") or self._terminal.terminal_initial_newline + self.get_option("terminal_initial_newline") + or self._terminal.terminal_initial_newline ) terminal_initial_prompt = ( @@ -683,11 +684,7 @@ def _connect(self): check_all = self.get_option("terminal_initial_prompt_checkall") or False if terminal_initial_newline: - self.send( - command=b"", - sendonly=True, - newline=True - ) + self.send(command=b"", sendonly=True, newline=True) self.receive( prompts=terminal_initial_prompt,