Hi. Im having trouble in my backup test playbook.
backed up files are is Amazon s3 bucket.
The problem is - we have many versions there. i need to limit rsync to latest version without providing it manually, or to prompt me for choice.
At the moment im stuck. I fail to find a module which could help me.
-
name: List s3 objects
aws_s3:
bucket: “bucket_name”
prefix: “application_folder”
max_keys: 3 *(application has 3 files in it so im trying to limit to the last 3 - unnsuccesfully though. )
mode: list
register: s3objects
become: yes
become_user: username -
debug: var=s3objects
-
name: write to file
copy:
content: “{{ s3objects }}”
dest: /home/username/application_folder_version
mode: 0644
force: yes
with_items: s3objects
become: yes
become_user: username
outcome:
“application/2018-08-21/1.78/application.properties”,
“application/2018-08-21/1.78/run.sh”,
“application/2018-08-21/1.78/application.jar”,
“application/2018-08-22/1.79/application.properties”,
“application/2018-08-22/1.79/run.sh”,
“application/2018-08-22/1.79/application.jar”,
“application/2018-08-30/1.80/application.properties”,
“application/2018-08-30/1.80/run.sh”,
“application/2018-08-30/1.80/application.jar”,
“application/2018-09-06/1.81/application.properties”,
“application/2018-09-06/1.81/run.sh”,
“application/2018-09-06/1.81/application.jar”,
“application/2018-09-07/1.81/application.properties”,
“application/2018-09-07/1.81/run.sh”,
“application/2018-09-07/1.81/application.jar”,
“application/2018-09-17/1.82/application.properties”,
“application/2018-09-17/1.82/run.sh”,
“application/2018-09-17/1.82/application.jar”,
“application/2018-10-11/1.83/application.properties”,
“application/2018-10-11/1.83/run.sh”,
“application/2018-10-11/1.83/application.jar”,
“application/2018-10-16/1.84/application.properties”,
“application/2018-10-16/1.84/run.sh”,
“application/2018-10-16/1.84/application.jar”,
“application/2018-10-18/1.85/application.properties”,
“application/2018-10-18/1.85/run.sh”,
“application/2018-10-18/1.85/application.jar”,
“application/2018-10-25/1.86/application.properties”,
“application/2018-10-25/1.86/run.sh”,
“application/2018-10-25/1.86/application.jar”,
“application/2018-10-31/1.87/application.properties”,
“application/2018-10-31/1.87/run.sh”,
“application/2018-10-31/1.87/application.jar”,
“application/2018-11-07/1.88/application.properties”,
“application/2018-11-07/1.88/run.sh”,
“application/2018-11-07/1.88/application.jar”
I could read last 3 lines from a file and take them as variables, but i don´t see how to do it with ansible.
Thanks for reading.