diff --git a/docs/ansible.netcommon.telnet_module.rst b/docs/ansible.netcommon.telnet_module.rst index 78a0020e2..dc697bfb7 100644 --- a/docs/ansible.netcommon.telnet_module.rst +++ b/docs/ansible.netcommon.telnet_module.rst @@ -164,6 +164,25 @@ Parameters <div>List of prompts expected before sending next command</div> </td> </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>send_carriage_return</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>no</b> ←</div></li> + <li>yes</li> + </ul> + </td> + <td> + <div>Sends a carriage return character upon successful connection to start the terminal session, this occurs before send_newline option.</div> + </td> + </tr> <tr> <td colspan="1"> <div class="ansibleOptionAnchor" id="parameter-"></div> diff --git a/plugins/action/telnet.py b/plugins/action/telnet.py index 74adb32a1..34d1fda14 100644 --- a/plugins/action/telnet.py +++ b/plugins/action/telnet.py @@ -48,6 +48,7 @@ def run(self, tmp=None, task_vars=None): timeout = int(self._task.args.get("timeout", 120)) pause = int(self._task.args.get("pause", 1)) + send_carriage_return = self._task.args.get("send_carriage_return", False) send_newline = self._task.args.get("send_newline", False) login_prompt = to_text(self._task.args.get("login_prompt", "login: ")) @@ -63,6 +64,8 @@ def run(self, tmp=None, task_vars=None): self.output = bytes() try: + if send_carriage_return: + self.tn.write(b"\r") if send_newline: self.tn.write(b"\n") diff --git a/plugins/modules/telnet.py b/plugins/modules/telnet.py index a5abac726..7b4fc49c7 100644 --- a/plugins/modules/telnet.py +++ b/plugins/modules/telnet.py @@ -78,12 +78,19 @@ required: false type: int default: 1 + send_carriage_return: + description: + - Sends a carriage return character upon successful connection to start the terminal session, this occurs before send_newline option. + required: false + type: bool + default: false send_newline: description: - Sends a newline character upon successful connection to start the terminal session. required: false type: bool default: false + notes: - The C(environment) keyword does not work with this task author: