Ansible-playbook for backing up running config of Cisco IOS

This ansible-playbook can be used to backup running configuration from Cisco IOS devices. You can refer to my earlier post Getting Started with your first ansible-playbook for Network Automation to know about the parameters used in this playbook.

Inventory file

# Inventory file for Ansible


- name: Define Parameters
  hosts: XE
  gather_facts: no
  connection: network_cli
   - name: backup the config
      backup: yes
     register: backup_config
   - name: Store the config to directory
      src: "{{ backup_config.backup_path }}"
      dest: "/tmp/backups/{{ inventory_hostname }}"

Running the playbook

[prashant@Prashant-VM01 ~]$ ansible-playbook play03.yml -i /home/prashant/inventory -u developer -k
SSH password:
PLAY [Define Parameters] **********************************************************************************************************
TASK [backup the config] **********************************************************************************************************
changed: []
changed: []
TASK [Store the config to directory] **********************************************************************************************
changed: []
changed: []
PLAY RECAP ************************************************************************************************************************ : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0      : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Verifying the backup files 

[prashant@Prashant-VM01 ~]$ cd /tmp/backups
[prashant@Prashant-VM01 backups]$ ls
[prashant@Prashant-VM01 backups]$

No comments:

Post a Comment