ansible_cache/ios_devices/device_backup.yml
2024-12-27 12:47:45 +00:00

28 lines
904 B
YAML
Executable File

---
## This playbook backs up the device configuration to a specific folder and tags it with timestamps
- name: Backup device configuration with timestamps
hosts: baguleykit
gather_facts: false
connection: network_cli
roles:
- common
tasks:
#Collect device information in order to use the hostname in the backup file name
- name: Collect device facts
ios_facts:
gather_subset: all
register: current_config
#Perform the backup and save it to a specific folder - in this case the path is set to be outside the GIT repository (for security purposes)
- name: Save configuration and back it up to local folder
ios_config:
backup: yes
backup_options:
dir_path: device_backups/
filename: "{{ current_config.ansible_facts.ansible_net_hostname }}-{{ '%Y-%m-%d' | strftime }}-{{ '%H:%M:%S' | strftime }}.backup"