ansible/test/integration/targets/incidental_azure_rm_resource/tasks/main.yml
Matt Clay e3591223a0
Second batch of incidental integration tests. (#67765)
* Update incidental test aliases.

* Rewrite target references for renamed targets.

* Add incidental tests to CI.

* Update sanity tests for incidental cloud tests.

* Initial copy of incidental tests.

* Copy contrib files into test.

* Update paths in test.

* Add support plugins.

* Update plugin to work around missing deps.

* Update sanity ignores.

* Fix matrix entries.

* Remove debug echo.
2020-02-25 23:18:50 -08:00

158 lines
4.2 KiB
YAML

- name: Prepare random number
set_fact:
nsgname: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
storageaccountname: "stacc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
dbname: "mdb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: yes
- name: Call REST API
azure_rm_resource:
api_version: '2018-02-01'
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
resource_name: "{{ nsgname }}"
body:
location: eastus
idempotency: yes
register: output
- name: Assert that something has changed
assert:
that: output.changed
- name: Call REST API
azure_rm_resource:
api_version: '2018-02-01'
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
resource_name: "{{ nsgname }}"
body:
location: eastus
idempotency: yes
register: output
- name: Assert that nothing has changed
assert:
that: not output.changed
- name: Call REST API
azure_rm_resource:
api_version: '2018-02-01'
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
resource_name: "{{ nsgname }}"
body:
location: eastus
tags:
a: "abc"
b: "cde"
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:
api_version: '2018-02-01'
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
resource_name: "{{ nsgname }}"
register: output
- name: Assert value was returned
assert:
that:
- not output.changed
- output.response[0]['name'] != None
- output.response | length == 1
- name: Try to query a list
azure_rm_resource_facts:
api_version: '2018-02-01'
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
register: output
- name: Assert value was returned
assert:
that:
- not output.changed
- output.response[0]['name'] != None
- output.response | length >= 1
- name: Try to query a list - same without API version
azure_rm_resource_facts:
resource_group: "{{ resource_group }}"
provider: network
resource_type: networksecuritygroups
register: output
- name: Assert value was returned
assert:
that:
- not output.changed
- output.response[0]['name'] != None
- output.response | length >= 1
- name: Query all the resources in the resource group
azure_rm_resource_facts:
resource_group: "{{ resource_group }}"
resource_type: resources
register: output
- name: Assert value was returned
assert:
that:
- not output.changed
- output.response | length >= 1
- name: Create storage account that requires LRO polling
azure_rm_resource:
polling_timeout: 600
polling_interval: 60
api_version: '2018-07-01'
resource_group: "{{ resource_group }}"
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 }}'"
- 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
- name: Delete storage - without API version
azure_rm_resource:
polling_timeout: 600
polling_interval: 60
method: DELETE
resource_group: "{{ resource_group }}"
provider: Storage
resource_type: storageAccounts
resource_name: "{{ storageaccountname }}"