ansible_cache/ios_devices/device_backup.yml

28 lines
908 B
YAML
Raw Normal View History

---
2021-04-22 08:49:53 +00:00
## This playbook backs up the device configuration to a specific folder and tags it with timestamps
- name: Backup device configuration with timestamps
hosts: homekit
gather_facts: false
connection: network_cli
roles:
- common
tasks:
2021-04-22 08:49:53 +00:00
#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
2021-04-22 08:49:53 +00:00
#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: ../../ansible_backups/
filename: "{{ current_config.ansible_facts.ansible_net_hostname }}-{{ '%Y-%m-%d' | strftime }}-{{ '%H:%M:%S' | strftime }}.backup"