ansible.netcommon
ansible.netcommon copied to clipboard
cannot use telnet module if a banner is applied within one of 'prompts' characters
SUMMARY
Issues faced case a banner is applied (on device that host telnet services) with one of those characters: '[>|#]'
ISSUE TYPE
In case one of those characters are applied on device that host telnet service banner '>|#' the output will be applied as something like: changed: [R3] => { "changed": true, "output": [ "#", "#", "#" ] }
COMPONENT NAME
ansible.netcommon.telnet
ANSIBLE VERSION
ansible 2.9.15 ansible-playbook 2.9.15
CONFIGURATION
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT
CentOS Linux release 8.2.2004 (Core) Running on Virtualbox 6.1.14 r140239 (Qt5.6.2) inside Microsoft Windows [Version 10.0.19042.572]
STEPS TO REPRODUCE
Create YAML files (see below), and run command: ansible-playbook -i /etc/ansible/inventory_telnet.yml /etc/ansible/commands.yml. Make sure device that has telnet service enabled has banner (for Cisco device: either 'banner motd', or 'banner login' enabled) with once of strings '>|#' characters. E.G. ########## Welcome ##########
inventory_telnet.yml
=========
telnet:
hosts:
R1:
ansible_host: "R3"
---------------
commands.yml
==========
- name: show version
hosts: telnet
gather_facts: false
connection: local
tasks:
- name: telnet sw
telnet:
user: cisco
password: cisco
login_prompt: "Username: "
prompts:
- '[>|#]'
command:
- terminal length 0
- sh run
EXPECTED RESULTS
I expect that script can also support device hostname, something like (...) prompts: - '$hostname[>|#]' (...)
ACTUAL RESULTS
# ansible-playbook -i /etc/ansible/inventory_telnet.yml /etc/ansible/commands.yml -vvvv
ansible-playbook 2.9.15
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/inventory_telnet.yml as it did not pass its verify_file() method
script declined parsing /etc/ansible/inventory_telnet.yml as it did not pass its verify_file() method
Parsed /etc/ansible/inventory_telnet.yml inventory source with yaml plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.6/site-packages/ansible/plugins/callback/default.py
PLAYBOOK: commands.yml ************************************************************************************************************
Positional arguments: /etc/ansible/commands.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/inventory_telnet.yml',)
forks: 5
1 plays in /etc/ansible/commands.yml
PLAY [show version] ***************************************************************************************************************
META: ran handlers
TASK [telnet sw] ******************************************************************************************************************
task path: /etc/ansible/commands.yml:6
changed: [R3] => {
"changed": true,
"output": [
"#",
"#",
"#"
]
}
META: ran handlers
META: ran handlers
PLAY RECAP ************************************************************************************************************************
R3 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
#