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
List of prompts expected before sending next command
+ + +
+ send_carriage_return + +
+ boolean +
+ + + + + +
Sends a carriage return character upon successful connection to start the terminal session, this occurs before send_newline option.
+ +
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: