annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 
cancel
270
Visites
0
Compliment
1
Réponses

Problem accessing Cisco Switch with Ansible

nikuiz
Level 1
Level 1

Hi everyone,

I'm currently discovering Ansible and I'm trying to write a simple playbook that prints out the running configuration of a Cisco switch. The IP address of the Switch is 192.168.0.1.

I've set up SSH authentication with a public key, which works perfectly fine from the machine that hosts Ansible ( ssh ANSIBLE@192.168.0.1 works fine, ANSIBLE being the username configured on the Switch ).

Here is my playbook :
nikuiz_0-1709560612235.png

Here is my ansible.cfg :
nikuiz_1-1709560642248.png

Here is my hosts file :
nikuiz_2-1709560687020.png

The problem is that everytime I run the playbook, I get the following error : "Invalid Key". At first I thought the private key I was using was bad, but after seeing the logs on the switch I think there's another problem - when connecting to the switch, ansible doesn't specify any username.

Here are the logs from the switch, first screen is a simple SSH connection ( ssh ANSIBLE@192.168.0.1 ), second one is when i run the playbook :

nikuiz_5-1709561118357.png

Why does Ansible doesn't specify any username when connecting to my switch? I've tried several methods to specify it, such as ansible_user: ANSIBLE in vars:, etc...  but none of them actually works.

Thanks for your help!

 

 

1 RÉPONSE 1

Quelques remarques:

1) Dans votre configuration je ne vois pas de mot de passe.

2) On peut voir qu'il y a un succes juste avant , il serait possible d'avoir les config en entier ? Ou à défaut vous pouvez refaire un test uniquement avec la config pour un seul switch ?

3) Voici un document de ansible sur ce type de retour

https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#error-authentication-failed

*** Obtenez des réponses techniques plus rapidement : Vidéo (15 min. fr) Visitez mon Blog technique. ***