Backing up the current, known good running configuration on a regular basis is an important part of documenting your network. Backing up configurations before and after changes is often an integral part of the change control process for production networks.
In this exercise, you will back up network device configurations.
Outcomes
You should be able to back up the configuration of a network device.
Open a terminal window on the workstation VM and change to the ~/proj/ directory.
Create a playbook named multi-vendor-backup3.yml that defaults to backing up configurations for all of the devices belonging to the network group.
Remember that you can also use the --limit=SUBSET (-l SUBSET) option to limit the target hosts to a particular group or host, as long as that group or host is a subset of the group or hosts specified in the hosts field of the playbook.
[student@workstation proj]$cat multi-vendor-backup3.yml--- - name: back up network device configurations hosts: network tasks: - name: backup config of vyos device vyos_config: backup: yes when: ansible_network_os == 'vyos' - name: backup config of ios device ios_config: backup: yes when: ansible_network_os == 'ios'
Perform the play in your playbook.
[student@workstation proj]$ansible-playbook multi-vendor-backup3.yml
Verify that device configurations were successfully backed up.
[student@workstation proj]$ls -l backup/total 20 -rw-rw-r--. 1 student student 1768 Aug 3 14:15 cs01_config.2020-08-03@14:15:52 -rw-rw-r--. 1 student student 2890 Aug 3 14:15 leaf01_config.2020-08-03@14:15:51 -rw-rw-r--. 1 student student 2903 Aug 3 14:15 leaf02_config.2020-08-03@14:15:51 -rw-rw-r--. 1 student student 2883 Aug 3 14:15 spine01_config.2020-08-03@14:15:51 -rw-rw-r--. 1 student student 2892 Aug 3 14:15 spine02_config.2020-08-03@14:15:51[student@workstation proj]$head -n 6 backup/*==> backup/cs01_config.2020-08-03@14:15:52 <== Building configuration... Current configuration : 1708 bytes ! ! Last configuration change at 14:51:02 UTC Mon Aug 3 2020 ! ==> backup/leaf01_config.2020-08-03@14:15:51 <== set interfaces ethernet eth0 address '172.25.250.151/24' set interfaces ethernet eth0 duplex 'auto' set interfaces ethernet eth0 hw-id '2c:c2:60:3c:26:65' set interfaces ethernet eth0 smp_affinity 'auto' set interfaces ethernet eth0 speed 'auto' set interfaces ethernet eth1 address '10.10.10.1/30' ==> backup/leaf02_config.2020-08-03@14:15:51 <== set interfaces ethernet eth0 address '172.25.250.161/24' set interfaces ethernet eth0 duplex 'auto' set interfaces ethernet eth0 hw-id '2c:c2:60:6b:20:19' set interfaces ethernet eth0 smp_affinity 'auto' set interfaces ethernet eth0 speed 'auto' set interfaces ethernet eth1 duplex 'auto' ...output omitted...
This concludes the guided exercise.