2017-08-12 10:03:42 +02:00
|
|
|
- name: Create storage account name
|
|
|
|
set_fact:
|
|
|
|
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Test invalid account name
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "invalid_char$"
|
|
|
|
state: present
|
|
|
|
register: invalid_name
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Assert task failed
|
|
|
|
assert: { that: "invalid_name['failed'] == True" }
|
|
|
|
|
|
|
|
- name: Delete storage account
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
state: absent
|
2019-02-18 09:48:56 +01:00
|
|
|
force_delete_nonempty: True
|
2017-08-12 01:16:39 +02:00
|
|
|
|
|
|
|
- name: Create new storage account
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
account_type: Standard_LRS
|
2018-08-16 05:35:39 +02:00
|
|
|
append_tags: no
|
2019-02-18 09:48:56 +01:00
|
|
|
blob_cors:
|
|
|
|
- allowed_origins:
|
|
|
|
- http://www.example.com/
|
|
|
|
allowed_methods:
|
|
|
|
- GET
|
|
|
|
- POST
|
|
|
|
allowed_headers:
|
|
|
|
- x-ms-meta-data*
|
|
|
|
- x-ms-meta-target*
|
|
|
|
- x-ms-meta-abc
|
|
|
|
exposed_headers:
|
|
|
|
- x-ms-meta-*
|
|
|
|
max_age_in_seconds: 200
|
2017-08-12 01:16:39 +02:00
|
|
|
tags:
|
|
|
|
test: test
|
|
|
|
galaxy: galaxy
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert status succeeded and results include an Id value
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
- output.state.id is defined
|
2019-02-18 09:48:56 +01:00
|
|
|
- output.state.blob_cors | length == 1
|
|
|
|
|
|
|
|
- name: Create new storage account (idempotence)
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ storage_account }}"
|
|
|
|
account_type: Standard_LRS
|
|
|
|
append_tags: no
|
|
|
|
blob_cors:
|
|
|
|
- allowed_origins:
|
|
|
|
- http://www.example.com/
|
|
|
|
allowed_methods:
|
|
|
|
- GET
|
|
|
|
- POST
|
|
|
|
allowed_headers:
|
|
|
|
- x-ms-meta-data*
|
|
|
|
- x-ms-meta-target*
|
|
|
|
- x-ms-meta-abc
|
|
|
|
exposed_headers:
|
|
|
|
- x-ms-meta-*
|
|
|
|
max_age_in_seconds: 200
|
|
|
|
tags:
|
|
|
|
test: test
|
|
|
|
galaxy: galaxy
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
2017-08-12 01:16:39 +02:00
|
|
|
|
|
|
|
- name: Gather facts by tags
|
|
|
|
azure_rm_storageaccount_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
tags:
|
|
|
|
- test
|
|
|
|
- galaxy
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: azure_storageaccounts | length >= 1
|
|
|
|
|
|
|
|
- name: Change account type
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
account_type: Premium_LRS
|
|
|
|
register: change_account
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Assert account type change failed
|
|
|
|
assert: { that: "change_account['failed'] == True" }
|
|
|
|
|
|
|
|
- name: Change account type and add custom domain
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
account_type: Standard_GRS
|
|
|
|
custom_domain: { name: ansible.com, use_sub_domain: no }
|
|
|
|
register: change_account
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Assert CNAME failure
|
|
|
|
assert: { that: "'custom domain name could not be verified' in change_account['msg']" }
|
|
|
|
|
|
|
|
- name: Update account tags
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2018-08-16 05:35:39 +02:00
|
|
|
append_tags: no
|
2017-08-12 01:16:39 +02:00
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: never
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "output.state.tags | length == 2"
|
|
|
|
- "output.state.tags.testing == 'testing'"
|
|
|
|
- "output.state.tags.delete == 'never'"
|
|
|
|
|
|
|
|
- name: Gather facts
|
|
|
|
azure_rm_storageaccount_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2019-02-18 09:48:56 +01:00
|
|
|
show_connection_string: True
|
|
|
|
show_blob_cors: True
|
2017-08-12 01:16:39 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "azure_storageaccounts| length == 1"
|
2019-02-18 09:48:56 +01:00
|
|
|
- "storageaccounts | length == 1"
|
|
|
|
- not storageaccounts[0].custom_domain
|
|
|
|
- storageaccounts[0].account_type == "Standard_GRS"
|
|
|
|
- storageaccounts[0].primary_endpoints.blob.connectionstring
|
|
|
|
- storageaccounts[0].blob_cors
|
2017-08-12 01:16:39 +02:00
|
|
|
|
|
|
|
- name: Gather facts
|
|
|
|
azure_rm_storageaccount_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "azure_storageaccounts | length > 0"
|
|
|
|
|
|
|
|
- name: Delete acccount
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-12 10:03:42 +02:00
|
|
|
name: "{{ storage_account }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
state: absent
|