Connect ssh to cisco switch with ansible

30 views Asked by At

I want to connect a ansible virtual machine to a cisco switch. When I try the command ssh [email protected] from my ansible manager, the connection is successfull but when I try to run a playbook from this same ansible manager I've this error: ssh connection failed: Failed to authenticate public key: Socket error: disconnected.

Does anyone have any idea what's wrong?

My playbook task with the command ansible-playbook -i inventaire.ini cisco.yml --user myuser --ask-pass:

---
- name: show version
  ios_command:
    commands:
      - show version
  register: output

- name: print output
  debug:
    var: output.stdout_lines

My variables:

ansible_network_os=ios
ansible_user=user-ansible
ansible_password=xxx
ansible_connection=network_cli

I've already try to create the ssh connection as this example. But without result.

1

There are 1 answers

0
Koяэn On

I find a way to avoid this error. I've updated my variables with my cisco user instead of my ansible user and now it's working :)