ansible-collections / cisco.ios

Ansible Network Collection for Cisco IOS
GNU General Public License v3.0
261 stars 162 forks source link

Ansible ios_command prompt issue #1063

Open andresgiuffre opened 3 weeks ago

andresgiuffre commented 3 weeks ago
SUMMARY

I'm sending a command to copy a file from a FTP server. The prompt will ask to confirm the file name, so I'm sending '\r' as the answer, as a carriage return. Everything works fine with many devices, but then a new file comes into play, and the file has a name similar to this: cModelx-universalk9.version.bin

So, I'm receiving the following error in the console:

Failed to compile one or more terminal prompt regexes: bad character range x-u at position 7

What's happening here is that the prompt is reading the filename string as if I were using regex, so it's treating that part of the name where you have the x-u as if I'm trying to tell "Hey! check for characters among the x and u letters!" ... of course, it won't work since x comes after the u letter. It's not failing with other file names. I have a file that has a-x in the string, and it's not failing.

ISSUE TYPE
COMPONENT NAME

ios_command

ANSIBLE VERSION
Ansible Automation Platform Controller v4.5.0
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE

Device is a Catalyst 2960x. The task works with other files, it's just this particular file in which you have that x-u as a part of the name.

- name: FTP Transfer
     ios_command:
       commands:
         - command: 'copy ftp://server/path/{{ filename }}'
            prompt: '[ {{ filename }} ]'
            answer: "\r"

"filename" is the variable containing a string with the name of the file.

EXPECTED RESULTS

The expected result is that the FTP transfer takes place smoothly

ACTUAL RESULTS

I just receive the following error:

Failed to compile one or more terminal prompt regexes: bad character range x-u at position 7

TASK [FTP Transfer] ****************************************

fatal: [DeviceName]: FAILED! => {"changed": false, "msg": "Failed to compile one or more terminal prompt regexes: bad character range x-u at position 7.\nPrompts provided: [b'[ cModelx-universalk9.version.bin ]']"}

Thursday 25 April 2024 18:55:17 +0000 (0:00:01.342) 0:02:03.969 ********