mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.9 KiB
YAML
117 lines
2.9 KiB
YAML
7 years ago
|
- name: Create storage account name
|
||
|
set_fact:
|
||
|
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
||
|
|
||
7 years ago
|
- name: Create storage account
|
||
|
azure_rm_storageaccount:
|
||
|
resource_group: "{{ resource_group }}"
|
||
7 years ago
|
name: "{{ storage_account }}"
|
||
7 years ago
|
account_type: Standard_LRS
|
||
|
state: present
|
||
|
|
||
|
- name: Create container
|
||
|
azure_rm_storageblob:
|
||
7 years ago
|
resource_group: "{{ resource_group }}"
|
||
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
|
||
|
- name: Force upload blob
|
||
|
azure_rm_storageblob:
|
||
|
resource_group: "{{ resource_group }}"
|
||
7 years ago
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
blob: 'Ratings.png'
|
||
7 years ago
|
src: './targets/azure_rm_storageblob/files/Ratings.png'
|
||
7 years ago
|
content_type: image/png
|
||
|
tags:
|
||
|
val1: foo
|
||
|
val2: bar
|
||
|
force: yes
|
||
|
|
||
|
- name: Upload blob idempotence
|
||
|
azure_rm_storageblob:
|
||
|
resource_group: "{{ resource_group }}"
|
||
7 years ago
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
blob: 'Ratings.png'
|
||
7 years ago
|
src: './targets/azure_rm_storageblob/files/Ratings.png'
|
||
7 years ago
|
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 }}"
|
||
7 years ago
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
blob: 'Ratings.png'
|
||
7 years ago
|
dest: './targets/azure_rm_storageblob/files/Ratings.png'
|
||
7 years ago
|
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 }}"
|
||
7 years ago
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
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:
|
||
7 years ago
|
resource_group: "{{ resource_group }}"
|
||
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
state: absent
|
||
|
register: output
|
||
|
|
||
|
- assert:
|
||
|
that: "not output.changed"
|
||
|
|
||
|
- name: Delete blob object
|
||
|
azure_rm_storageblob:
|
||
|
resource_group: "{{ resource_group }}"
|
||
7 years ago
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
blob: "Ratings.png"
|
||
|
state: absent
|
||
|
register: output
|
||
|
|
||
|
- assert:
|
||
|
that: "output.changed"
|
||
|
|
||
|
- name: Delete container
|
||
|
azure_rm_storageblob:
|
||
7 years ago
|
resource_group: "{{ resource_group }}"
|
||
|
account_name: "{{ storage_account }}"
|
||
7 years ago
|
container_name: my-blobs
|
||
|
state: absent
|
||
|
register: output
|
||
|
|
||
|
- assert:
|
||
|
that: "output.changed"
|
||
|
|
||
|
- name: Delete storage account
|
||
|
azure_rm_storageaccount:
|
||
|
resource_group: "{{ resource_group }}"
|
||
7 years ago
|
name: "{{ storage_account }}"
|
||
7 years ago
|
state: absent
|