citizenBane
citizenBane

Reputation: 347

Copying files from S3 buckets in Ansible

I was wondering whether the copy module can be used to deploy my installation tarball from an AWS S3 bucket to an EC2 instance?

Upvotes: 5

Views: 17605

Answers (2)

Lakshmikandan
Lakshmikandan

Reputation: 4647

file_root: File/directory path for synchronization. This is a local path, key_prefix: In addition to the file path, prepend s3 path with this prefix. A module will add a slash at end of prefix if necessary.

- name: "copy to S3 bucket"
  s3_sync:
    bucket: your-bucket-name
    file_root: "/tmp/file.txt"
    key_prefix: Deployment
    file_change_strategy: force
    include: "*"
    permission: private
    mode: push

http://docs.ansible.com/ansible/latest/modules/s3_sync_module.html

Upvotes: 1

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68289

There is s3 for this task:

Excerpt from examples:

# Simple GET operation
- s3: bucket=mybucket object=/my/desired/key.txt dest=/usr/local/myfile.txt mode=get

But this requires boto and AWS credentials on target host.

You may want to make download url with mode=geturl with local action and then fetch it on your target box.

Upvotes: 5

Related Questions