I have created a task to do a backup of my Mikrotik switches every morning, and copy the backup file to a shared folder on my Ansible server (Debian 12).
Ansible are installed from apt:
ansible: 7.7.0+dfsg-3+deb12u1
ansible-core: 2.14.18-0+deb12u2
My playbook:
- name: Backup all RouterOS switches
hosts: routeros
gather_facts: no
remote_user: ansible
tasks:
- name: Run backup and check to see if output says its saved
community.routeros.command:
commands: /system/backup/save dont-encrypt=yes name=/auto
retries: 1
wait_for: result[0] contains Configuration backup saved
- name: Retrieve the backup file from RouterOS
ansible.builtin.fetch:
src: auto.backup
dest: /mnt/backup/routeros/{{ inventory_hostname }}.backup
flat: true
The backup file are created successfully on the Mikrotik device.
But if the file already exists in the backup dir on the Ansible server, it is not replaced.
The fetch job works 100% if I delete the target files before I run the playbook.
There is no overwrite option in the fetch module, so is there another module I could try?
I do not want to delete the backup file before I know that it will be replaced.
As a developer I could fix this with a few lines in a bash script, but I would like for it to work in a playbook.
Iâm trying to install PIP (which I do not like), and will see if I can upgrade the module to something that works.
As a 60 year old programmer based on Pascal, C+ and other common languages, I will say I do hate containers. And by hate, I mean HATE! âapt purge docker*â
So I hope there is some way for me to use this without those technologies.
I can live with pip, itâs not that bad, just.. well.. bad.
i suspect it is not just pip, but âlanguage based package managersâ ⌠some of us prefer the system package managers when it comes to host installations, for many reasons, specially if we are/were sysadmins.
Maybe. Things can get complicated when you need something that isnât packaged up by the OSâs package manager though. Alas, not everything can be as elegant as âC+â.