ansible-collections / ansible.netcommon

Ansible Network Collection for Common Code
GNU General Public License v3.0
143 stars 104 forks source link

ansible.netcommon.cli_command prompt does not match known host fingerprint response. #663

Open Githopp opened 3 months ago

Githopp commented 3 months ago
SUMMARY
ISSUE TYPE
COMPONENT NAME

ansible.netcommon.cli_command

ANSIBLE VERSION
  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/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 1.5.0  

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 7.0.0  
CONFIGURATION
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye

target OS: Aruba 6000 AOSCX

STEPS TO REPRODUCE
- name: AOS-CX Collector
  hosts: arubaos-cx
  gather_facts: no
  collections:
   - arubanetworks.aoscx

  vars:
    ansible_network_os: arubanetworks.aoscx.aoscx
    ansible_user: manager
    ansible_connection: network_cli 
    ansible_host_key_checking: false
    ansible_python_interpreter: /usr/bin/python3
    ansible_aoscx_validate_certs: false
    ansible_aoscx_use_proxy: false
    ansible_acx_no_proxy: true

  tasks:
    - name: "Show Config"
      aoscx_command:
        commands: ['show images']

      register: show_aoscx_output

    - debug:
        msg: "{{output.stdout_lines}}"

    - name: SSH on SFTP for confirmation
      ansible.netcommon.cli_command: 
        command: ssh sftpuser@192.168.1.16
        check_all: true
        prompt:
        - '.*'
        - Password
        answer:
        - yes\n
        - thepassword
EXPECTED RESULTS

The authenticity of host ... can't be established. ED25519 key fingerprint is SHA256:jfwKE8. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])?

prompt should send 'yes'

I tried different combinations of prompt 'the authencity', 'connecting', it triggers timeout.

when I accept the host key via switch cli, the command produces expected result, eg password is send connection established

TASK [SSH on SFTP for confirmation] **** ok: [192.168.1.16]

TASK [debug] *** ok: [192.168.1.16] => { "msg": [ "sftpuser@2::251's password: ", "thepassword", "thepassword", "This service allows sftp connections only.", "Connection to 2::251 closed." ] }

ACTUAL RESULTS

fatal: [192.168.1.16]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}