Skip to content
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

Answer switch causes "Invalid input" error in netcommon.cli_command #561

Open
worshach opened this issue Jul 7, 2023 · 0 comments
Open
Assignees

Comments

@worshach
Copy link

worshach commented Jul 7, 2023

SUMMARY

When using prompt/answer, the answer always causes the fatal error "Invalid input"

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cli_command

ANSIBLE VERSION
ansible [core 2.14.2]
  config file = /workbench/cesi_testing/netcommon_cli_test_01/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Jun 14 2023, 13:00:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.2)] (/usr/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
ansible.netcommon 5.1.2  
CONFIGURATION
CONFIG_FILE() = /workbench/cesi_testing/netcommon_cli_test/ansible.cfg
DEFAULT_GATHERING(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = ['/workbench/cesi_testing/netcommon_cli_test_01/hosts']
DEFAULT_LOG_PATH(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = /workbench/cesi_testing/netcommon_cli_test_01/logs/ansible.log
HOST_KEY_CHECKING(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = False
NETWORK_GROUP_MODULES(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = ['os10']
RETRY_FILES_ENABLED(/workbench/cesi_testing/netcommon_cli_test/ansible.cfg) = False
OS / ENVIRONMENT

Dell SmartFabric OS10 Enterprise
OS Version: 10.5.5.3
Build Version: 10.5.5.3.56
Build Time: 2023-04-21T06:03:38+0000
System Type: S5248F-VM
Architecture: x86_64

STEPS TO REPRODUCE

Use prompt/answer switches and any answer fails

---
- hosts: leaf01
  connection: network_cli
  vars:
    ansible_persistent_log_messages: True
    ansible_network_os: dellemc.os10.os10

  tasks:
  - name: configure services for management vrf
    ansible.netcommon.cli_command:
      command: |
        configure
        ip scp vrf management
      prompt:
        - (?i)Do you want to continue
      answer: 'yes'
EXPECTED RESULTS

leaf01(config)# ip scp vrf management
% Warning: SCP client will be disabled in default VRF and enabled on management VRF
Do you want to continue ? [yes/no(default)]:yes
leaf01(config)#

ACTUAL RESULTS

2023-07-06 21:40:20,415 p=1477367 u=root n=ansible | ansible-playbook [core 2.14.2]
config file = /workbench/cesi_testing/netcommon_cli_test_01/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.11/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.11.2 (main, Jun 14 2023, 13:00:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.2)] (/usr/bin/python3.11)
jinja version = 3.1.2
libyaml = True
2023-07-06 21:40:20,416 p=1477367 u=root n=ansible | Using /workbench/cesi_testing/netcommon_cli_test_01/ansible.cfg as config file
2023-07-06 21:40:20,426 p=1477367 u=root n=ansible | host_list declined parsing /workbench/cesi_testing/netcommon_cli_test_01/hosts as it did not pass its verify_file() method
2023-07-06 21:40:20,427 p=1477367 u=root n=ansible | script declined parsing /workbench/cesi_testing/netcommon_cli_test_01/hosts as it did not pass its verify_file() method
2023-07-06 21:40:20,427 p=1477367 u=root n=ansible | auto declined parsing /workbench/cesi_testing/netcommon_cli_test_01/hosts as it did not pass its verify_file() method
2023-07-06 21:40:20,428 p=1477367 u=root n=ansible | Parsed /workbench/cesi_testing/netcommon_cli_test_01/hosts inventory source with yaml plugin
2023-07-06 21:40:20,493 p=1477367 u=root n=ansible | Skipping callback 'default', as we already have a stdout callback.
2023-07-06 21:40:20,493 p=1477367 u=root n=ansible | Skipping callback 'minimal', as we already have a stdout callback.
2023-07-06 21:40:20,494 p=1477367 u=root n=ansible | Skipping callback 'oneline', as we already have a stdout callback.
2023-07-06 21:40:20,494 p=1477367 u=root n=ansible | PLAYBOOK: site.yaml *************************************************************************************************************************************************************************************************************
2023-07-06 21:40:20,494 p=1477367 u=root n=ansible | 1 plays in site.yaml
2023-07-06 21:40:20,496 p=1477367 u=root n=ansible | PLAY [leaf01] *******************************************************************************************************************************************************************************************************************
2023-07-06 21:40:20,566 p=1477367 u=root n=ansible | TASK [configure services for management vrf] ************************************************************************************************************************************************************************************
2023-07-06 21:40:20,642 p=1477367 u=root n=ansible | redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
2023-07-06 21:40:21,210 p=1477389 u=root n=ansible | redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
2023-07-06 21:40:21,254 p=1477389 u=root n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "pop_messages", "id": "ce3be42a-737b-4e07-b950-65c79b7cec75", "params": [[], {}]}'
2023-07-06 21:40:21,254 p=1477389 u=root n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "ce3be42a-737b-4e07-b950-65c79b7cec75", "result_type": "pickle", "result": "(lp0\n(Vvvvv\np1\nVloaded cliconf plugin ansible_collections.dellemc.os10.plugins.cliconf.os10 from path /root/.ansible/collections/ansible_collections/dellemc/os10/plugins/cliconf/os10.py for network_os dellemc.os10.os10\np2\ntp3\na(Vlog\np4\nVnetwork_os is set to dellemc.os10.os10\np5\ntp6\na(Vwarning\np7\nVPersistent connection logging is enabled for 172.16.27.90. This will log ALL interactions to /workbench/cesi_testing/netcommon_cli_test_01/logs/ansible.log and WILL NOT redact sensitive configuration like passwords. USE WITH CAUTION!\np8\ntp9\na(g1\nVssh type is set to auto\np10\ntp11\na(g1\nVautodetecting ssh_type\np12\ntp13\na(g1\nVssh type is now set to libssh\np14\ntp15\na."}
2023-07-06 21:40:21,350 p=1477367 u=root n=ansible | network_os is set to dellemc.os10.os10
2023-07-06 21:40:21,351 p=1477367 u=root n=ansible | [WARNING]: Persistent connection logging is enabled for 172.16.27.90. This will log ALL interactions to /workbench/cesi_testing/netcommon_cli_test_01/logs/ansible.log and WILL NOT redact sensitive configuration like
passwords. USE WITH CAUTION!

2023-07-06 21:40:21,355 p=1477389 u=root n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "get", "id": "b2f305e0-fa49-4c06-b186-785aa0f9b19f", "params": [[], {"command": "configure\nip scp vrf management\n", "prompt": ["(?i)Do you want to continue"], "answer": ["yes"], "newline": true, "sendonly": false, "check_all": false}]}'
2023-07-06 21:40:21,356 p=1477389 u=root n=ansible | [DEPRECATION WARNING]: PlayContext.verbosity is deprecated, use
ansible.utils.display.Display.verbosity instead. This feature will be removed
in version 2.18. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
2023-07-06 21:40:21,356 p=1477389 u=root n=ansible | <172.16.27.90> USING PYLIBSSH VERSION 1.1.0
2023-07-06 21:40:21,356 p=1477389 u=root n=ansible | <172.16.27.90> ESTABLISH LIBSSH CONNECTION FOR USER: admin on PORT 22 TO 172.16.27.90
2023-07-06 21:40:21,428 p=1477389 u=root n=ansible | ssh connection is OK: <pylibsshext.session.Session object at 0x7f04a3e7b420>
2023-07-06 21:40:24,968 p=1477389 u=root n=ansible | Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ansible/utils/jsonrpc.py", line 46, in handle_request
result = rpc_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.ansible/collections/ansible_collections/dellemc/os10/plugins/cliconf/os10.py", line 84, in get
return self.send_command(command=command, prompt=prompt, answer=answer, sendonly=sendonly, newline=newline, check_all=check_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansible/plugins/cliconf/init.py", line 127, in send_command
resp = self._connection.send(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py", line 339, in wrapped
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py", line 997, in send
response = self.receive(
^^^^^^^^^^^^^
File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py", line 938, in receive
response = self.receive_libssh(
^^^^^^^^^^^^^^^^^^^^
File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py", line 903, in receive_libssh
raise AnsibleConnectionFailure(errored_response)
ansible.errors.AnsibleConnectionFailure: configure terminal
leaf01(config)# ip scp vrf management
% Warning: SCP client will be disabled in management VRF and enabled on management VRF
Do you want to continue ? [yes/no(default)]:yes
Invalid input, expected [yes/no]
leaf01(config)#

2023-07-06 21:40:24,969 p=1477389 u=root n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "b2f305e0-fa49-4c06-b186-785aa0f9b19f", "error": {"code": -32603, "message": "Internal error", "data": "configure terminal\r\nleaf01(config)# ip scp vrf management\r\n% Warning: SCP client will be disabled in management VRF and enabled on management VRF\r\nDo you want to continue ? [yes/no(default)]:yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# "}}
2023-07-06 21:40:24,977 p=1477367 u=root n=ansible | The full traceback is:
File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py", line 170, in main
response = connection.get(**module.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansible/module_utils/connection.py", line 200, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)

2023-07-06 21:40:24,977 p=1477367 u=root n=ansible | fatal: [leaf01]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"answer": [
"yes"
],
"check_all": false,
"command": "configure\nip scp vrf management\n",
"newline": true,
"prompt": [
"(?i)Do you want to continue"
],
"sendonly": false
}
},
"msg": "configure terminal\r\nleaf01(config)# ip scp vrf management\r\n% Warning: SCP client will be disabled in management VRF and enabled on management VRF\r\nDo you want to continue ? [yes/no(default)]:yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# "
}
2023-07-06 21:40:24,978 p=1477389 u=root n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "reset", "id": "3c444ee6-f5d8-46e8-8328-d75067b3e313", "params": [[], {}]}'
2023-07-06 21:40:24,979 p=1477389 u=root n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "3c444ee6-f5d8-46e8-8328-d75067b3e313", "result_type": "pickle", "result": "N."}
2023-07-06 21:40:24,995 p=1477367 u=root n=ansible | PLAY RECAP **********************************************************************************************************************************************************************************************************************
2023-07-06 21:40:24,995 p=1477367 u=root n=ansible | leaf01 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | invoked shell using ssh_type: libssh
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | ssh connection done, setting terminal
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | loaded terminal plugin for network_os dellemc.os10.os10
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | command: None
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-1: b'Linux leaf01 4.19.249 #1d SMP Debian 4.19.249-2+dn1 x86_64\r\nTEST\r\n'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-2: b'%Warning : Default password for admin account should be changed to secure the system\r\n'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-3: b'%Warning : Default password for linuxadmin account should be changed to secure the system.\r\n'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-4: b'leaf01# '
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | matched cli prompt 'b'\nleaf01# '' with regex 'b'[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\\)]+\)){,3}(?:#) ?$'' from response 'b'Linux leaf01 4.19.249 #1d SMP Debian 4.19.249-2+dn1 x86_64\r\nTEST\r\n%Warning : Default password for admin account should be changed to secure the system\r\n%Warning : Default password for linuxadmin account should be changed to secure the system.\r\nleaf01# ''
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | firing event: on_open_shell()
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | send command: b'terminal length 0\r'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | command: b'terminal length 0'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-1: b'te'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-2: b'rminal length 0'
2023-07-06 21:40:25,080 p=1477389 u=root n=ansible | response-3: b'\r\nleaf01# '
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched cli prompt 'b'\nleaf01# '' with regex 'b'[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\\)]+\)){,3}(?:#) ?$'' from response 'b'terminal length 0\r\nleaf01# ''
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | ssh connection has completed successfully
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | send command: b'configure\nip scp vrf management\n\r'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | command: b'configure\nip scp vrf management\n'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-1: b'c'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-2: b'onfigure terminal\r\n'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-3: b'leaf01(config)# ip'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-4: b' sc'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-5: b'p vrf management\r\n'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-6: b'% Warning: SCP client will be disabled in management VRF and enabled on management VRF'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-7: b'\r\nDo you want to continue ? [yes/no(default)]:'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched command prompt: b'Do you want to continue'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched command prompt answer: b'yes\r'
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | response-8: b'yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# '
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched error regex (terminal_stderr_re) 'b'invalid input'' from response 'b'configure terminal\r\nleaf01(config)# ip scp vrf management\r\n% Warning: SCP client will be disabled in management VRF and enabled on management VRF\r\nDo you want to continue ? [yes/no(default)]:yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# ''
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched stdout regex (terminal_stdout_re) 'b'[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\\)]+\)){,3}(?:#) ?$'' from error response 'b'configure terminal\r\nleaf01(config)# ip scp vrf management\r\n% Warning: SCP client will be disabled in management VRF and enabled on management VRF\r\nDo you want to continue ? [yes/no(default)]:yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# ''
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | matched cli prompt 'b'\nleaf01(config)# '' with regex 'b'[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\\)]+\)){,3}(?:#) ?$'' from response 'b'configure terminal\r\nleaf01(config)# ip scp vrf management\r\n% Warning: SCP client will be disabled in management VRF and enabled on management VRF\r\nDo you want to continue ? [yes/no(default)]:yes\r\nInvalid input, expected [yes/no]\r\nleaf01(config)# ''
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | resetting persistent connection for socket_path /root/.ansible/pc/d72d619fda
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | closing ssh connection to device
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | firing event: on_close_shell()
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | cli session is now closed
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | ssh connection has been closed successfully
2023-07-06 21:40:25,081 p=1477389 u=root n=ansible | reset call on connection instance
2023-07-06 21:40:25,082 p=1477389 u=root n=ansible | shutdown complete

Invalid input, expected [yes/no]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants