top of page
Recent Posts
  • Writer's pictureZakir

Ansible: How to take CISCO switch backup?

Device configuration backup is vital task for IT people especially those who are working as a administrator. To make this task easier i have create Ansible playbook for CISCO switches. Below i will show how this playbook actually works.

vim /etc/ansible/hosts

# Insert below lines at the end of the file.

SW-148 ansible_host= ansible_network_os=ios

cd /etc/ansible/playbooks

vim cisco-sw-bkp.yaml

- hosts: all
  gather_facts: true
  connection: network_cli
  become: yes

  - name: Show Running Configuration
      host: "{{ cisco }}"
        - show run
    register: config
  - name: Save output to /etc/ansible/backups
     content: "{{ config.stdout[0] }}"
     dest: "/etc/ansible/backups/show_run_config_{{ inventory_hostname }}.txt"


Run The Playbook

# ansible-playbook -l cisco playbooks/cisco.yaml -k -u admin

If everything is ok. You will get a backup file in /etc/ansible/backups/ location named as show_run_config_192.168.11.148.txt

If you do not want to type password during playbook execution you have to modify your playbook as like below:

# vim /etc/ansible/hosts

SW-148 ansible_host= ansible_network_os=ios ansible_ssh_user=admin  ansible_ssh_pass="admin" 

Then run the playbook

# ansible-playbook -l cisco playbooks/cisco.yaml
549 views0 comments

Recent Posts

See All

How to install tomcat web server in a portable way?

Apache Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies. Tomcat provides a "pure Java" HTTP web server environment in


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page