le 04-03-2024 06:09 AM
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 :
Here is my ansible.cfg :
Here is my hosts file :
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 :
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!
le 05-03-2024 08:24 PM
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
Découvrez et enregistrez vos notes préférées. Revenez pour trouver les réponses d'experts, des guides étape par étape, des sujets récents et bien plus encore.
Êtes-vous nouveau ici? Commencez par ces conseils. Comment utiliser la communauté Guide pour les nouveaux membres
Parcourez les liens directs de la Communauté et profitez de contenus personnalisés en français