SUMMARY
When sending some specific commands to Cisco CBS350 the connection time's out.
ISSUE TYPE
COMPONENT NAME
Module send commands
ANSIBLE VERSION
ansible [core 2.15.1]
config file = .../ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/.local/bin/ansible
python version = 3.9.17 (main, Aug 9 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
community.ciscosmb 1.0.6
CONFIGURATION
[defaults]
use_persistent_connections = true
host_key_checking = false
timeout = 120
[persistent_connection]
command_timeout = 60
OS / ENVIRONMENT
Device: Cisco CBS350-24XTS
Version: 3.3.0.16
Name: paramiko
Version: 3.3.1
STEPS TO REPRODUCE
hosts:
[SWITCH-CBS350]
10.55.100.11
[SWITCH-CBS350:vars]
ansible_connection: network_cli
ansible_network_cli_ssh_type: paramiko
ansible_network_os: community.ciscosmb.ciscosmb
ansible_ssh_user: admin
ansible_ssh_password: pass12345
cisco-cbs.yml:
- name: Cisco CBS
hosts: SWITCH-CBS350
gather_facts: false
tasks:
- name: Configure Cisco CBS
community.ciscosmb.command:
commands:
- configure terminal
- clock timezone EET 2 minutes 0
- clock summer-time EET recurring eu
EXPECTED RESULTS
ansible-playbook cisco-cbs.yml
PLAY [Cisco CBS]
TASK [Configure Cisco CBS]
ok: [SWITCH-CBS350]
ACTUAL RESULTS
TASK [ Configure Cisco CBS]
fatal: [SWITCH-CBS350]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}
ADDITIONAL INFOS
The behavior from CLI.
Commands:
clock timezone EET 2 minutes 0
clock summer-time EET recurring eu
Output:
SWITCH-CBS350(config)#clock summer-time EET recurring eu
23-Mar-2023 14:59:17 %TIMEMANAGE-N-SMTIMEUPDATE: Summer-time updated: previous: None; new: begins Last Sun of Mar 01:00, ends Last Sun of Oct 01:00 offset 60 (acronym EET)
SWITCH-CBS350(config)#23-Mar-2023 14:59:17 %STCK SYSL-N-UNITTRP: UNIT ID 2,Trap:%TIMEMANAGE-N-SMTIMEUPDATE: Summer-time updated: previous: None; new: begins Last Sun of Mar 01:00, ends Last Sun of Oct 01:00 offset 60 (acronym EET)
(Note that the prompt "SWITCH-CBS350(config)#" is missing )
Output from a device (CBS220-24P-4G Version: 2.0.2.8) that doesn't experience this issue:
SWITCH-CBS350(config)#clock summer-time EET recurring eu
SWITCH-CBS350(config)#
(Note that the prompt "SWITCH-CBS350(config)#" is present )
Same goes for the clock timezone EET 2 minutes 0
Other commands that I have tested that don't have the issue of missing prompt are working.
When running these commands from SSH, an ENTER is needed in order to give other commands.
The first time the play runs, it applies the command and exists with time-out. If I run the play a second time it finishes successfully.
WORKAROUND
Modifying the "get" function defined in ../ansible_collections/community/ciscosmb/plugins/cliconf/ciscosmb.py " with "+ "\n"" for the command parameter fixes this issue.
Diff Exeample:
--- plugins/cliconf/ciscosmb.py.orig 2023-09-08 13:48:15
+++ plugins/cliconf/ciscosmb.py 2023-09-08 13:51:45
@@ -70,7 +70,7 @@
return
def get(self, command, prompt=None, answer=None, sendonly=False, newline=True, check_all=False):
-- return self.send_command(command=command, prompt=prompt, answer=answer, sendonly=sendonly, newline=newline, check_all=check_all)
++ return self.send_command(command=command + "\n", prompt=prompt, answer=answer, sendonly=sendonly, newline=newline, check_all=check_all)
def get_capabilities(self):
result = super().get_capabilities()
Also, setting "sendonly=TRUE" fixes this issue, but I did not find anyway of setting it directly from ansible.