03-25-2024 12:30 AM
Hello Team,
Hope you are all well.
I have this challenge when i try to run a playbook to back up network devices.
am attaching the playbook config and the error.
- name: AUTOMATIC BACKUP OF RUNNING-CONFIG
hosts: Core_Switch
gather_facts: true
connection: local
tasks:
- name: DISPLAYING THE RUNNING-CONFIG
ios_command:
commands:
- show run
timeout: 30
host: "{{ ansible_host }}"
username: xxxxx
password: yyyyy
register: config
- name: Get Current Date
local_action: command date +%Y-%b-%d
register: date
- name: Get Current Time
local_action: command date +%H:%M
register: time
- name: save Output to /home/user1/Backups
copy:
content: "{{ config.stdout[0] }}"
dest: "/home/user1/Backups/_{{ date.stdout }}_at_{{ time.stdout }}-{{ inventory_hostname }}.txt"
Error is as below :-
03-25-2024 12:57 AM - edited 03-25-2024 03:00 AM
You have connection: local
, which is meant for tasks executed on the Ansible control machine itself.
Update the connection
line to specify a connection type suitable for network devices.
connection: network_cli
I would also set the ansible_network_os
variable to cisco.ios.ios
to ensure Ansible uses the correct libraries.
03-25-2024 01:22 AM
Here the error am now getting.
03-25-2024 01:38 AM
You seem to be missing the paramiko python module. It can be installed using pip, likely with the command "python3 -m pip install paramiko" depending on your OS.
03-25-2024 02:06 AM
03-25-2024 02:59 AM
This could be one of two things based on the error incorrect credential and/or you are missing ansible-pylibssh library (pip install this)
Hope this helps.
03-25-2024 05:04 AM
Credentials are ok, since they can ssh to the device, Installed the library as well.
Anything else I might be missing?
03-25-2024 05:41 AM - edited 03-25-2024 05:42 AM
can you run this with -vvvv and share the output, the only thing the last error is showing is the wrong creds, this will giev a more verbose output that might include additional details about the authentication failure in the error, also can you share the inventory file too?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide