ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
82 stars 68 forks source link

Unable to execute commands containing a questionmark using eos_command via network_cli #510

Open ccsnw opened 8 months ago

ccsnw commented 8 months ago
SUMMARY

In a specific use-case, I need to execute a command containing a Questionmark "?" using the eos_command module through network_cli. This fails, as typing the "?" on Cli will lead to an immediate response from the device showing valid commands that can followup what has already been typed.

When manually working on the CLI, you can "escape" the "?" by typing CTRL+V followed by the "?". I haven't found any option to achieve something similar using the eos_command module.

Is there a character that can be used to escape the "?" or is there some cli-context that will not interpret the "?" dynamically (as soon as it is typed)?

You can replicate the issue with the following command (just an example):

sh int status | grep -P '^((?!Not).)*$'

The command should list all Ports (sh int status) which don't contain the string "Not" (aiming at the "Not present" when no transceiver is inserted)

- name: test
  eos_command:
     commands:
       - sh int status | grep -P '^((?!Not).)*$'

Let me know if further info is needed

ISSUE TYPE

I think the behaviour is somehow expected (due to how CLI behaves when you input a "?"). But this behaviour kinda limits the use, so it would be great to have some sort of workaround

COMPONENT NAME

arista.eos.eos_command module

ANSIBLE VERSION
ansible [core 2.12.10]
COLLECTION VERSION
arista.eos        6.1.2
STEPS TO REPRODUCE

You can replicate the issue with the following command (just an example):

sh int status | grep -P '^((?!Not).)*$'

The command should list all Ports (sh int status) which don't contain the string "Not" (aiming at the "Not present" when no transceiver is inserted)

- name: test
  eos_command:
     commands:
       - sh int status | grep -P '^((?!Not).)*$'