Making use of Ansible to collect backup files ,show tech and see the versions of Cisco switches. I use docker container to run the ansible playbooks.
Inventory file:-
Create an inventory file
[switches]
R1 ansible_host=10.60.51.1
[switches:vars]
ansible_connection=network_cli
ansible_network_os=ios
ansible_user=admin
ansible_password=cisco
ansible_become=yes
ansible_become_method=enable
Yaml File:-
Create a yaml file. The below code will save the Backup and show tech file on the root folder with the device name.
---
- name: Cisco ios devices
hosts: switches
gather_facts: no
connection: network_cli
tasks:
- name: Backup
ios_command:
commands:
- show running-config
- show tech-support
register: cisco_config
- name: Save the config
copy:
content: "{{ cisco_config.stdout[0] }}"
dest: "~/{{ inventory_hostname }}_backup.txt"
- name: Get show tech support
copy:
content: "{{ cisco_config.stdout[1] }}"
dest: "~/{{ inventory_hostname }}_show_tech.txt"
- name: CHECK CURRENT VERSION
ios_facts:
- debug:
msg:
- "Current version is {{ ansible_net_version }}"
...
Run Ansible Playbook:-
ansible-playbook -i inventory version.yaml

Hello,
Thank you for sharing the blogs with us. This is one of the best way to take backup and tech support using ansible.
LikeLike