-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gns3 iosv telnet #580
base: main
Are you sure you want to change the base?
Gns3 iosv telnet #580
Conversation
add sending of "\r" if send_carriage_return flag is true, allows connection to IOSv devices console under GNS3
…wline It makes more sense to send to do send_carriage_return before send_newline. Not only is this the expected order "\r\n" but in case of cisco iosV on GNS3 the send_carriage_return needs be the first thing send to get any response.
…wline It makes more sense to send to do send_carriage_return before send_newline. Not only is this the expected order "\r\n" but in case of cisco iosV on GNS3 the send_carriage_return needs be the first thing send to get any response.
for more information, see https://pre-commit.ci
I think this is a functional duplicate of #440, do you agree? I feel like an option to change whether explicit carriage returns are used globally is a little clearer, but I'm not sure if there is some reason to only need a carriage return on that first interaction |
I have tested with ansible.netcommon 5.2.0 and while it does function the terminal output now consists of blank line between every command: With the plain send_carriage_return option output is : If I register this output I get reasonably clean output: But using the crlf method it is a mess and small changes in plays seem to drastically effect what get registered. I would need test this further but so far the crlf creates more issues for me that it solves. On a more general theme #440 changes the line ending used throughout the play including changing behavior of the send_newline flag. It seem to me this is doing double duty for two functions that could/should be considered separate. It would be better to have these so in play line ending can be change independent of the send_newline flag which really should just sent "\n". Perhaps a better approach would to have a line_ending option to set the preferred line ending and a separate generic send_on_start where an arbitrary character can be specified upon successful connection to start the terminal session. That way you can have "\r", "\r\n", "\n" or any other characters as the first thing sent. |
SUMMARY
Add "send_carriage_return" option to send "\r" upon connection similar to existing send-newline.
This add ability to connect to IOSv devices in GNS3 which need get the "/r" as the first character in the telnet connection otherwise the prompt is never found. It seem that a carriage return is required to display the NAG banner after which the prompt is output.
Issue #542 describes similar issue with nag banner on Procurve switches
ISSUE TYPE
COMPONENT NAME
ansible.netcommon.telnet
ADDITIONAL INFORMATION
Using GNS3 a new project is created with a single IOSv router con0 is made available on 198.18.1.200:500.
The last output on the console is "%PLATFORM-5-SIGNATURE_VERIFIED: Image 'flash0:/vios-adventerprisek9-m' passed code signing verification" and the IOSv then waits for a "\r" before display in the NAG and prompt:
Router#
SO using the inventory :-
all:
hosts:
R1:
ansible_host: 198.18.1.200
port: 5000
device_type: "cisco_ios_telnet"
and playbook :-
gather_facts: false
hosts: all
tasks:
telnetX:
port: '{{ hostvars[inventory_hostname].port }}'
timeout: 5
prompts:
- '[>#]'
command:
- configure terminal
- hostname {{ inventory_hostname }}
results in output :
(.venv) local@ansible:$ansible-playbook -i ./ansible/inventory/telnetX_hosts.yml ./ansible/telnetX.yml
PLAY [Configure hostname using Telnet connection] ********************************************************************
TASK [Configure hostname] ********************************************************************************************
fatal: [R1]: FAILED! => {"changed": true, "msg": "Telnet timed out trying to find prompt(s): '['[>#]']'", "stdout": "", "stdout_lines": []}
PLAY RECAP ***********************************************************************************************************
R1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
(.venv) local@ansible:$
This is the second run as the first output all the startup output from the device but results in the same behaviour.
With support for sending carriage return and adding send_carriage_return: true send_carriage_return: true to the task :-
gather_facts: false
hosts: all
tasks:
telnetX:
port: '{{ hostvars[inventory_hostname].port }}'
timeout: 5
send_carriage_return: true
prompts:
- '[>#]'
command:
- configure terminal
- hostname {{ inventory_hostname }}
(.venv) adm-local@ansible:$ansible-playbook -i ./ansible/inventory/telnetX_hosts.yml ./ansible/telnetX.yml
PLAY [Configure hostname using Telnet connection] ********************************************************************
TASK [Configure hostname] ********************************************************************************************
changed: [R1]
PLAY RECAP ***********************************************************************************************************
R1 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
(.venv) adm-local@ansible:$