All I wanted to do was to fetch files for OTAP purposes. Well ....
I tried fetch, combining it with copying files to a backup folder and using fdupes (not installed by default). But i needed the backup files to include a timestamp. Well you can imagine my playbook grew and grew with set_facts and what not (i did not give up without a fight). The playbook filled my screen with useless information and on top of it all, it did not work like i wanted it to.
So i resorted to back to old trusty rsync and now have a nice simple single task in my playbook
- How are others implementing this?
- Anything missing by any change?
vars:
files_to_sync:
- file1
- file2
fetchfiles: /root/ansible/fetchfiles
tasks:
- name: sync file to master
local_action: shell rsync -abci --backup-dir=backup --suffix=_`date '+%Y%m%d.%H%M%S'` {{ ansible_user_id }}@{{ ansible_fqdn }}:'{{ files_to_sync | join(' ') }}' {{ fetchfiles }}/{{ inventory_hostname }}
register: mastersync
changed_when: mastersync.stdout
i use the -c option of rsync, because i dump sql tables to temporary files, so the timestamp does get changed
the -i option to itemize changes to report actual changes