Forum Discussion
Ansible F5 Backup
I've trawled the internet and Dev/Central to find a suitable Ansible playbook to do the following.
Backup and F5 with the same filename so that I can push to our Gitlab for version control.
The Ansible modules seem to either generate a random filename which isn't reusable in a playbook, if I specify source then the current UCS does not get overwritten, if I copy to the local filesystem with the same target name the module appends date and time to the file which will not give any consistency to GItlab.
This is so far what I have come up with, the code is in its most basic form for testing only.
- name: Clean the local backup directory
path: "{{ item }}"
state: absent
with_fileglob:
- "/ansible//dailybackups/*"
connection: local
- name: Clean the previous UCS file from F5
bigip_ucs:
state: absent
ucs: "{{ inventory_hostname }}.ucs"
provider:
server: 1.1.1.1
user: admin
password: admin
validate_certs: no
delegate_to: localhost
- name: Save the running configuration of the BIG-IP
bigip_ucs_fetch:
backup: yes
src: "{{ inventory_hostname }}.ucs"
dest: /ansible/dailybackups/{{ inventory_hostname }}.ucs
provider:
server: 1.1.1.1
user: admin
password: admin
validate_certs: no
delegate_to: localhost
So to perform a repeatable function I am forced to delete the file from the local file system to be copied to, erase the current UCS file on the F5 which is used as the backup, and then backup the F5 and pull the file to the local file system. Surely there is a slicker way of doing what can be done on a Cisco device in 4 lines.
(NB) I have excluded the Git function, these 3 plays are merely to pull a consistent named UCS file and store to the local filesystem.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com