2017-05-31 17:48:35 +02:00
|
|
|
---
|
|
|
|
# tasks file for test_s3
|
2018-06-06 17:22:52 +02:00
|
|
|
|
2018-01-10 00:05:22 +01:00
|
|
|
- name: set up aws connection info
|
|
|
|
set_fact:
|
|
|
|
aws_connection_info: &aws_connection_info
|
|
|
|
aws_access_key: "{{ aws_access_key }}"
|
|
|
|
aws_secret_key: "{{ aws_secret_key }}"
|
|
|
|
security_token: "{{ security_token }}"
|
|
|
|
region: "{{ aws_region }}"
|
|
|
|
no_log: yes
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- block:
|
2019-07-10 23:05:13 +02:00
|
|
|
- name: Create temporary directory
|
|
|
|
tempfile:
|
|
|
|
state: directory
|
|
|
|
register: tmpdir
|
|
|
|
|
|
|
|
- name: Create content
|
|
|
|
set_fact:
|
|
|
|
content: "{{ lookup('password', '/dev/null chars=ascii_letters,digits,hexdigits,punctuation') }}"
|
|
|
|
|
2018-06-07 19:13:11 +02:00
|
|
|
- name: test create bucket without permissions
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: create
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- assert:
|
2018-06-07 19:13:11 +02:00
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- "result.msg != 'MODULE FAILURE'"
|
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test create bucket
|
2018-01-10 00:05:22 +01:00
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: create
|
|
|
|
<<: *aws_connection_info
|
2018-06-06 17:22:52 +02:00
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: trying to create a bucket name that already exists
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: create
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- name: Create local upload.txt
|
2018-06-06 17:22:52 +02:00
|
|
|
copy:
|
|
|
|
content: "{{ content }}"
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/upload.txt"
|
|
|
|
|
|
|
|
- name: stat the file
|
2018-06-06 17:22:52 +02:00
|
|
|
stat:
|
2019-07-10 23:05:13 +02:00
|
|
|
path: "{{ tmpdir.path }}/upload.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
get_checksum: yes
|
2019-07-10 23:05:13 +02:00
|
|
|
register: upload_file
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test putting an object in the bucket
|
2018-01-10 00:05:22 +01:00
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
2019-07-10 23:05:13 +02:00
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: delete.txt
|
2018-01-10 00:05:22 +01:00
|
|
|
<<: *aws_connection_info
|
2018-06-06 17:22:52 +02:00
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
- result.msg == "PUT operation complete"
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-07 21:09:22 +02:00
|
|
|
- name: test using aws_s3 with async
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
2019-07-10 23:05:13 +02:00
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
2018-06-07 21:09:22 +02:00
|
|
|
object: delete.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: test_async
|
|
|
|
async: 30
|
|
|
|
poll: 0
|
2019-07-10 23:05:13 +02:00
|
|
|
|
2018-06-07 21:09:22 +02:00
|
|
|
- name: ensure it completed
|
|
|
|
async_status:
|
|
|
|
jid: "{{ test_async.ansible_job_id }}"
|
|
|
|
register: status
|
2018-07-30 10:41:49 +02:00
|
|
|
until: status is finished
|
2018-06-07 21:09:22 +02:00
|
|
|
retries: 10
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- name: test put with overwrite=different and unmodified object
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: check that roles file lookups work as expected
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
|
|
|
src: hello.txt
|
2019-07-10 23:05:13 +02:00
|
|
|
object: delete.txt
|
2018-06-06 17:22:52 +02:00
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
- result.msg == "PUT operation complete"
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- name: test put with overwrite=never
|
2018-06-06 17:22:52 +02:00
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
2019-07-10 23:05:13 +02:00
|
|
|
mode: put
|
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: never
|
2018-06-06 17:22:52 +02:00
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
|
|
|
|
- name: test put with overwrite=different and modified object
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: test put with overwrite=always
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: always
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test get object
|
2018-01-10 00:05:22 +01:00
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: delete.txt
|
2018-01-10 00:05:22 +01:00
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2018-06-06 17:22:52 +02:00
|
|
|
register: result
|
2018-01-10 00:05:22 +01:00
|
|
|
until: "result.msg == 'GET operation complete'"
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- name: stat the file so we can compare the checksums
|
2018-06-06 17:22:52 +02:00
|
|
|
stat:
|
2019-07-10 23:05:13 +02:00
|
|
|
path: "{{ tmpdir.path }}/download.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
get_checksum: yes
|
2019-07-10 23:05:13 +02:00
|
|
|
register: download_file
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- upload_file.stat.checksum == download_file.stat.checksum
|
|
|
|
|
|
|
|
- name: test get with overwrite=different and identical files
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
|
|
|
|
- name: modify destination
|
|
|
|
copy:
|
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
|
|
|
src: hello.txt
|
|
|
|
|
|
|
|
- name: test get with overwrite=never
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: never
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is not changed
|
|
|
|
|
|
|
|
- name: test get with overwrite=different and modified file
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: test get with overwrite=always
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
|
|
|
object: delete.txt
|
|
|
|
overwrite: always
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test geturl of the object
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: geturl
|
|
|
|
object: delete.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
until: result is changed
|
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
|
|
|
- "'Download url:' in result.msg"
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test getstr of the object
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: getstr
|
|
|
|
object: delete.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2018-01-10 00:05:22 +01:00
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
|
|
|
- result.msg == "GET operation complete"
|
|
|
|
- result.contents == content
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test list to get all objects in the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: list
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-01-10 00:05:22 +01:00
|
|
|
that:
|
2018-06-06 17:22:52 +02:00
|
|
|
- "'delete.txt' in result.s3_keys"
|
|
|
|
- result.msg == "LIST operation complete"
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test delobj to just delete an object in the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delobj
|
|
|
|
object: delete.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
|
|
|
- "'Object deleted from bucket' in result.msg"
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test putting an encrypted object in the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
2019-07-10 23:05:13 +02:00
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
encrypt: yes
|
|
|
|
object: delete_encrypt.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
- result.msg == "PUT operation complete"
|
|
|
|
|
|
|
|
- name: test get encrypted object
|
2018-01-10 00:05:22 +01:00
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/download_encrypted.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: delete_encrypt.txt
|
2018-01-10 00:05:22 +01:00
|
|
|
<<: *aws_connection_info
|
2018-06-06 17:22:52 +02:00
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2018-01-10 00:05:22 +01:00
|
|
|
register: result
|
2018-06-06 17:22:52 +02:00
|
|
|
until: "result.msg == 'GET operation complete'"
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- name: stat the file so we can compare the checksums
|
2018-06-06 17:22:52 +02:00
|
|
|
stat:
|
2019-07-10 23:05:13 +02:00
|
|
|
path: "{{ tmpdir.path }}/download_encrypted.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
get_checksum: yes
|
2019-07-10 23:05:13 +02:00
|
|
|
register: download_file
|
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- upload_file.stat.checksum == download_file.stat.checksum
|
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: delete encrypted file
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delobj
|
|
|
|
object: delete_encrypt.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test putting an aws:kms encrypted object in the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
2019-07-10 23:05:13 +02:00
|
|
|
src: "{{ tmpdir.path }}/upload.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
encrypt: yes
|
|
|
|
encryption_mode: aws:kms
|
|
|
|
object: delete_encrypt_kms.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-01-10 00:05:22 +01:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
- result.msg == "PUT operation complete"
|
2018-01-10 00:05:22 +01:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test get KMS encrypted object
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/download_kms.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: delete_encrypt_kms.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
|
|
|
until: "result.msg == 'GET operation complete'"
|
2019-07-10 23:05:13 +02:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: get the stat of the file so we can compare the checksums
|
|
|
|
stat:
|
2019-07-10 23:05:13 +02:00
|
|
|
path: "{{ tmpdir.path }}/download_kms.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
get_checksum: yes
|
2019-07-10 23:05:13 +02:00
|
|
|
register: download_file
|
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- upload_file.stat.checksum == download_file.stat.checksum
|
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
# FIXME - could use a test that checks uploaded file is *actually* aws:kms encrypted
|
2019-07-10 23:05:13 +02:00
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: delete KMS encrypted file
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delobj
|
|
|
|
object: delete_encrypt_kms.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
|
|
|
|
# FIXME: could use a test that checks non standard KMS key
|
|
|
|
# but that would require ability to create and remove such keys.
|
|
|
|
# PRs exist for that, but propose deferring until after merge.
|
|
|
|
|
|
|
|
- name: test creation of empty path
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: create
|
|
|
|
object: foo/bar/baz/
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
|
|
|
- "'Virtual directory foo/bar/baz/ created' in result.msg"
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
|
|
|
|
2018-06-06 17:22:52 +02:00
|
|
|
- name: test deletion of empty path
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delobj
|
|
|
|
object: foo/bar/baz/
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
|
|
|
|
- name: test delete bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delete
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2019-07-10 23:05:13 +02:00
|
|
|
until: result is changed
|
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test create a bucket with a dot in the name
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name + '.bucket' }}"
|
|
|
|
mode: create
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test delete a bucket with a dot in the name
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name + '.bucket' }}"
|
|
|
|
mode: delete
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: test delete a nonexistent bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name + '.bucket' }}"
|
|
|
|
mode: delete
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
2019-07-10 23:05:13 +02:00
|
|
|
|
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is not changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: make tempfile 4 GB for OSX
|
|
|
|
command:
|
2019-07-10 23:05:13 +02:00
|
|
|
_raw_params: "dd if=/dev/zero of={{ tmpdir.path }}/largefile bs=1m count=4096"
|
2018-06-06 17:22:52 +02:00
|
|
|
when: ansible_distribution == 'MacOSX'
|
|
|
|
|
|
|
|
- name: make tempfile 4 GB for linux
|
|
|
|
command:
|
2019-07-10 23:05:13 +02:00
|
|
|
_raw_params: "dd if=/dev/zero of={{ tmpdir.path }}/largefile bs=1M count=4096"
|
2018-06-06 17:22:52 +02:00
|
|
|
when: ansible_system == 'Linux'
|
|
|
|
|
|
|
|
- name: test multipart download - platform specific
|
|
|
|
block:
|
|
|
|
- name: make a bucket to upload the file
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: create
|
|
|
|
<<: *aws_connection_info
|
|
|
|
|
|
|
|
- name: upload the file to the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: put
|
2019-07-10 23:05:13 +02:00
|
|
|
src: "{{ tmpdir.path }}/largefile"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: multipart.txt
|
|
|
|
<<: *aws_connection_info
|
|
|
|
|
|
|
|
- name: download file once
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: multipart.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
retries: 3
|
|
|
|
delay: 3
|
|
|
|
until: "result.msg == 'GET operation complete'"
|
|
|
|
register: result
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is changed
|
2018-06-06 17:22:52 +02:00
|
|
|
|
|
|
|
- name: download file again
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: get
|
2019-07-10 23:05:13 +02:00
|
|
|
dest: "{{ tmpdir.path }}/download.txt"
|
2018-06-06 17:22:52 +02:00
|
|
|
object: multipart.txt
|
|
|
|
overwrite: different
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: result
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- assert:
|
2018-06-06 17:22:52 +02:00
|
|
|
that:
|
2019-07-10 23:05:13 +02:00
|
|
|
- result is not changed
|
2018-06-06 17:22:52 +02:00
|
|
|
when: ansible_system == 'Linux' or ansible_distribution == 'MacOSX'
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: remove uploaded files
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delobj
|
|
|
|
object: "{{ item }}"
|
|
|
|
<<: *aws_connection_info
|
2019-07-10 23:05:13 +02:00
|
|
|
loop:
|
2018-06-06 17:22:52 +02:00
|
|
|
- hello.txt
|
|
|
|
- delete.txt
|
|
|
|
- delete_encrypt.txt
|
|
|
|
- delete_encrypt_kms.txt
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2019-07-10 23:05:13 +02:00
|
|
|
- name: delete temporary files
|
2018-01-10 00:05:22 +01:00
|
|
|
file:
|
|
|
|
state: absent
|
2019-07-10 23:05:13 +02:00
|
|
|
path: "{{ tmpdir.path }}"
|
2018-06-06 17:22:52 +02:00
|
|
|
ignore_errors: yes
|
2018-01-10 00:05:22 +01:00
|
|
|
|
|
|
|
- name: delete the bucket
|
|
|
|
aws_s3:
|
|
|
|
bucket: "{{ bucket_name }}"
|
|
|
|
mode: delete
|
|
|
|
<<: *aws_connection_info
|
2018-06-06 17:22:52 +02:00
|
|
|
ignore_errors: yes
|