2017-08-12 08:03:42 +00:00
|
|
|
- name: Create storage account name
|
|
|
|
set_fact:
|
|
|
|
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
|
|
|
|
2017-08-11 23:16:39 +00:00
|
|
|
- name: Create storage account
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
account_type: Standard_LRS
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create container
|
|
|
|
azure_rm_storageblob:
|
2017-08-12 08:03:42 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
|
|
|
|
- name: Force upload blob
|
|
|
|
azure_rm_storageblob:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
blob: 'Ratings.png'
|
2017-08-12 08:03:42 +00:00
|
|
|
src: './targets/azure_rm_storageblob/files/Ratings.png'
|
2017-08-11 23:16:39 +00:00
|
|
|
content_type: image/png
|
|
|
|
tags:
|
|
|
|
val1: foo
|
|
|
|
val2: bar
|
|
|
|
force: yes
|
|
|
|
|
2018-03-23 02:55:04 +00:00
|
|
|
- name: storage blob seems to have some timing issues
|
|
|
|
wait_for:
|
|
|
|
delay: 10
|
|
|
|
|
2017-08-11 23:16:39 +00:00
|
|
|
- name: Upload blob idempotence
|
|
|
|
azure_rm_storageblob:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
blob: 'Ratings.png'
|
2017-08-12 08:03:42 +00:00
|
|
|
src: './targets/azure_rm_storageblob/files/Ratings.png'
|
2017-08-11 23:16:39 +00:00
|
|
|
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 }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
blob: 'Ratings.png'
|
2017-08-12 08:03:42 +00:00
|
|
|
dest: './targets/azure_rm_storageblob/files/Ratings.png'
|
2017-08-11 23:16:39 +00:00
|
|
|
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 }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
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:
|
2017-08-12 08:03:42 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: "not output.changed"
|
|
|
|
|
|
|
|
- name: Delete blob object
|
|
|
|
azure_rm_storageblob:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
blob: "Ratings.png"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: "output.changed"
|
|
|
|
|
|
|
|
- name: Delete container
|
|
|
|
azure_rm_storageblob:
|
2017-08-12 08:03:42 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
account_name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
container_name: my-blobs
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: "output.changed"
|
|
|
|
|
|
|
|
- name: Delete storage account
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 08:03:42 +00:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-11 23:16:39 +00:00
|
|
|
state: absent
|