Hi. Im trying to automate our restore machine testing.
At one point i need to connect to amason S3 and download the latest data from a bucket.
What i have tried thus far:
- name: List s3 objects
aws_s3:
prefix: "/application_name/"
dest: /home/user/tmp-file
mode: list
max_keys: 5
register: s3objects
become: yes
become_user: user
- name: show list?
debug:
msg: "heres the list: {{ s3objects.s3_keys }}"
- name: write to file
copy:
content: "{{ s3objects }}"
dest: /home/user/tmp-file
with_items: s3objects.s3_keys
become: yes
become_user: user
The tmp file has this info:
"{"msg": "LIST operation complete", "failed": false, "changed": false, "s3_keys": []}"
Im very new to ansible, what i would ultimately want is to get this:
aws s3 ls s3://
bucet.name/application_name/ | tail -5