2018-05-23 23:55:57 +00:00
|
|
|
- name: Prepare random number
|
|
|
|
set_fact:
|
2018-06-07 06:11:00 +00:00
|
|
|
nsgname: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
2018-07-31 08:31:08 +00:00
|
|
|
storageaccountname: "stacc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
2018-12-17 05:21:25 +00:00
|
|
|
dbname: "mdb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
2018-05-23 23:55:57 +00:00
|
|
|
run_once: yes
|
|
|
|
|
2018-06-07 06:11:00 +00:00
|
|
|
- name: Call REST API
|
2018-05-23 23:55:57 +00:00
|
|
|
azure_rm_resource:
|
2018-06-07 06:11:00 +00:00
|
|
|
api_version: '2018-02-01'
|
2018-05-23 23:55:57 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-07 06:11:00 +00:00
|
|
|
provider: network
|
|
|
|
resource_type: networksecuritygroups
|
|
|
|
resource_name: "{{ nsgname }}"
|
2018-05-23 23:55:57 +00:00
|
|
|
body:
|
|
|
|
location: eastus
|
|
|
|
idempotency: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert that something has changed
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
2018-06-07 06:11:00 +00:00
|
|
|
- name: Call REST API
|
2018-05-23 23:55:57 +00:00
|
|
|
azure_rm_resource:
|
2018-06-07 06:11:00 +00:00
|
|
|
api_version: '2018-02-01'
|
2018-05-23 23:55:57 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-07 06:11:00 +00:00
|
|
|
provider: network
|
|
|
|
resource_type: networksecuritygroups
|
|
|
|
resource_name: "{{ nsgname }}"
|
2018-05-23 23:55:57 +00:00
|
|
|
body:
|
|
|
|
location: eastus
|
|
|
|
idempotency: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert that nothing has changed
|
|
|
|
assert:
|
|
|
|
that: not output.changed
|
|
|
|
|
2018-06-07 06:11:00 +00:00
|
|
|
- name: Call REST API
|
2018-05-23 23:55:57 +00:00
|
|
|
azure_rm_resource:
|
2018-06-07 06:11:00 +00:00
|
|
|
api_version: '2018-02-01'
|
2018-05-23 23:55:57 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-07 06:11:00 +00:00
|
|
|
provider: network
|
|
|
|
resource_type: networksecuritygroups
|
|
|
|
resource_name: "{{ nsgname }}"
|
2018-05-23 23:55:57 +00:00
|
|
|
body:
|
|
|
|
location: eastus
|
2018-06-07 06:11:00 +00:00
|
|
|
tags:
|
|
|
|
a: "abc"
|
|
|
|
b: "cde"
|
2018-05-23 23:55:57 +00:00
|
|
|
idempotency: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert that something has changed
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: Try to get information about account
|
|
|
|
azure_rm_resource_facts:
|
2018-06-07 06:11:00 +00:00
|
|
|
api_version: '2018-02-01'
|
2018-05-23 23:55:57 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-07 06:11:00 +00:00
|
|
|
provider: network
|
|
|
|
resource_type: networksecuritygroups
|
|
|
|
resource_name: "{{ nsgname }}"
|
2018-05-23 23:55:57 +00:00
|
|
|
register: output
|
2018-07-31 08:31:08 +00:00
|
|
|
|
2018-12-17 05:21:25 +00:00
|
|
|
- name: Create storage account that requires LRO polling
|
|
|
|
azure_rm_resource:
|
|
|
|
polling_timeout: 600
|
|
|
|
polling_interval: 60
|
|
|
|
api_version: '2018-07-01'
|
2018-07-31 08:31:08 +00:00
|
|
|
resource_group: "{{ resource_group }}"
|
2018-12-17 05:21:25 +00:00
|
|
|
provider: Storage
|
|
|
|
resource_type: storageAccounts
|
|
|
|
resource_name: "{{ storageaccountname }}"
|
|
|
|
body:
|
|
|
|
sku:
|
|
|
|
name: Standard_GRS
|
|
|
|
kind: Storage
|
|
|
|
location: eastus
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert that storage was successfully created
|
|
|
|
assert:
|
|
|
|
that: "output['response']['name'] == '{{ storageaccountname }}'"
|
|
|
|
|
2018-07-31 08:31:08 +00:00
|
|
|
|
|
|
|
- name: Try to storage keys -- special case when subresource part has no name
|
|
|
|
azure_rm_resource:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
provider: storage
|
|
|
|
resource_type: storageAccounts
|
|
|
|
resource_name: "{{ storageaccountname }}"
|
|
|
|
subresource:
|
|
|
|
- type: listkeys
|
|
|
|
api_version: '2018-03-01-preview'
|
|
|
|
method: POST
|
|
|
|
register: keys
|
|
|
|
|
|
|
|
- name: Assert that key was returned
|
|
|
|
assert:
|
|
|
|
that: keys['response']['keys'][0]['value'] | length > 0
|
2018-12-17 05:21:25 +00:00
|
|
|
|
|
|
|
- name: Delete storage
|
|
|
|
azure_rm_resource:
|
|
|
|
polling_timeout: 600
|
|
|
|
polling_interval: 60
|
|
|
|
method: DELETE
|
|
|
|
api_version: '2018-07-01'
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
provider: Storage
|
|
|
|
resource_type: storageAccounts
|
|
|
|
resource_name: "{{ storageaccountname }}"
|