1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/azure_rm_storageblob/tasks/main.yml
Matt Clay 3631163329 Clean up and migrate Azure tests. (#28103)
* Remove placeholder Azure test.
* Migrate Azure tests to ansible-test.
* Initial cleanup on remaining legacy Azure tests.
2017-08-12 01:03:42 -07:00

116 lines
2.9 KiB
YAML

- name: Create storage account name
set_fact:
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
- name: Create storage account
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
account_type: Standard_LRS
state: present
- name: Create container
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
- name: Force upload blob
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
src: './targets/azure_rm_storageblob/files/Ratings.png'
content_type: image/png
tags:
val1: foo
val2: bar
force: yes
- name: Upload blob idempotence
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
src: './targets/azure_rm_storageblob/files/Ratings.png'
content_type: image/png
tags:
val1: foo
val2: bar
register: upload_facts
- assert:
that: "not upload_facts.changed"
- name: Download file idempotence
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
dest: './targets/azure_rm_storageblob/files/Ratings.png'
register: download_results
- assert:
that: not download_results.changed
- file: path="/tmp/Ratings.png" state=absent
- name: Download file
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
dest: '/tmp/Ratings.png'
register: download_results
- assert:
that: "download_results.changed"
- find: paths='/tmp' patterns="Ratings.png"
register: find_results
- assert: { that: "find_results['matched'] == 1" }
- name: Do not delete container that has blobs
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
state: absent
register: output
- assert:
that: "not output.changed"
- name: Delete blob object
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: "Ratings.png"
state: absent
register: output
- assert:
that: "output.changed"
- name: Delete container
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
state: absent
register: output
- assert:
that: "output.changed"
- name: Delete storage account
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
state: absent