Copying whole directory from amazon S3 using ansible

I have a script that downloads stuff from amazon S3

Downloading file works perfectly but in one scenario i want to download whole directory from the bucket.

Ansible seems to require file name in object and destination

Is anyone aware of how to do this?

Code to download file from amazon S3

s3: bucket={{bucket_name}} object={{filename_to_download}} dest={{destination_dir}}/{{src_filename}} s3_url={{amazon_s3_url}} mode=get

Code I tried to download whole dir (want to download all files in current dir)

s3: bucket={{bucket_name}} object=/resource/current/ dest={{destination_dir}}/current/ s3_url={{amazon_s3_url}} mode=get

i get following error

IOError: [Errno 21] Is a directory: ‘/destination/current/’

Thanks

The s3 module does not support directory uploads, or any recursion.
For this tasks, I'd recommend using s3cmd --sync or a similar tool and
launching it with the command module.

- James

You can do this in 2 steps:
1.
s3:
bucket: “{{bucket_name}}”
prefix: “{{path_to_download}}”
s3_url: "{{amazon_s3_url}}
mode: list
register: s3list

s3:

bucket: “{{bucket_name}}”
object: “{{ item }}”
s3_url: "{{amazon_s3_url}}
dest: “{{ destination_dir }}/{{ item|basename }}”
mode: get
with_items: “{{ s3list.s3_keys }}”